tar Command Generator — Build & Decode tar Commands
Nobody remembers tar flags. Pick what you want and get the exact command —
with every flag explained. Or paste a tar command and have it decoded.
Runs entirely in your browser, no signup.
Your command
—
Or: decode a tar command
Paste any tar command — every flag gets explained.
The tar flags, demystified
The reason tar feels impossible is that one letter changes everything. The core
three are mutually exclusive — pick exactly one: c create,
x extract, t list. Everything else is
a modifier. The two you'll always want are f (the archive filename comes next) and
v (verbose, so you can see what's happening). So tar -czvf out.tar.gz dir/
reads as "create, gzip, verbose, file out.tar.gz from dir/".
Which compression should I use?
- gzip (.gz) — the default everyone has. Fast, decent ratio. Use it unless you have a reason not to.
- zstd (.zst) — the modern winner: gzip-level speed with much better ratios.
Great if both ends have a recent
tar. - xz (.xz) — smallest files, but slow to compress. Good for release archives you build once and download many times.
- bzip2 (.bz2) — older middle ground; zstd or xz beat it on both axes now.
Gotchas worth knowing
fmust come last in a bundled flag group, because the filename is its argument:-czvf name.tar.gzworks,-cfzv name.tar.gzdoes not.- Extract goes into the current directory by default. A "tar bomb" that
wasn't packed inside a folder will spray files everywhere —
listit first, or extract into a fresh dir with-C newdir. - "tar: Removing leading /" is normal. tar strips the leading slash so the
archive isn't tied to an absolute path. Use
-Ponly if you really want absolute paths (you usually don't). - Modern tar auto-detects compression on extract, so
tar -xf file.tar.zstworks without the format flag — but being explicit never hurts. - Use
-Cto set the directory, notcdchains.tar -czf bk.tar.gz -C /var/www sitearchivessiterelative to/var/www, keeping clean paths inside the archive.
Frequently asked questions
How do I extract a .tar.gz file?
tar -xzvf file.tar.gz — extract, gzip, verbose, file. On modern tar even
tar -xf file.tar.gz works because it auto-detects gzip.
What does tar -xzvf mean?
x extract, z through gzip, v verbose (print each file),
f the archive filename follows. It's the classic "unzip a .tar.gz" command.
How do I create a tar.gz of a folder?
tar -czvf archive.tar.gz folder/. Add --exclude='*.log' to skip files,
or -C parentdir folder to control the paths stored inside.
gzip vs zstd vs xz — which is best?
zstd for the best speed-to-size balance, xz for the smallest files, gzip for maximum compatibility. All three are one flag apart.
Working with permissions too? See the chmod calculator, or browse all tools on the home page.