tar command generator
Nobody remembers tar’s flags. I’ve used it for years and I still second-guess myself. So pick what you want here, create, extract or list, choose a compression format, tick a couple of options, and copy a tar command that just runs. Honestly the best part is the explanation underneath: it tells you what -czvf actually does, letter by letter. The command gets built right on this page, nothing phones home.
What this tar command generator does
tar rolls a pile of files into one archive, and if you add a compression filter, it squashes that archive down too. Great. The catch is the flag syntax, which is genuinely awful to remember. One letter separates -czf from -xzf, and that letter decides whether you’re creating an archive or unpacking one over your current files. This thing lets you click the operation in plain words and spits out the exact command. You copy something that works on the first try instead of guessing and maybe clobbering a folder.
You pick one of four operations, and only one. create (-c) builds a new archive. extract (-x) unpacks one. list (-t) just shows you what’s inside without touching anything, which I lean on more than I’d like to admit. And append (-r) tacks files onto an existing uncompressed archive. Then -f always sits right before the archive name. The compression flag picks the filter: -z for gzip, -j for bzip2, -J for xz, --zstd for Zstandard.
How to read a tar command
Take tar -czvf backup.tar.gz /etc. Read it left to right: create (c), gzip (z), verbose (v), file (f) called backup.tar.gz, holding /etc. You can jam the short flags together behind one dash. But f has to be last in the bundle, because whatever comes next is its value, the filename. Put f in the middle and tar grabs the wrong word as your archive name. Modern GNU tar usually sniffs out the compression on extraction, so tar -xf archive.tar.gz works fine without -z. Being explicit anyway keeps your scripts happy on BSD tar, which is the kind of thing you forget until a Mac breaks your build.
- Zip a folder into a gzip archive:
tar -czvf site.tar.gz public_html/ - Unpack it right where you are:
tar -xzvf site.tar.gz - Unpack it somewhere else instead:
tar -xzvf site.tar.gz -C /var/www - Peek inside without unpacking anything:
tar -tzvf site.tar.gz
Choosing a compression format
| Flag | Format | Trade-off |
|---|---|---|
-z | gzip | Fast and everywhere. Ratio is fine. Pick this when you’re not sure. |
-j | bzip2 | Squeezes tighter than gzip but drags. Mostly a legacy thing now. |
-J | xz | Smallest output, also the slowest and hungriest for memory. Made for release tarballs. |
--zstd | Zstandard | gzip-ish ratios but way faster. The modern pick when both sides have it. |
Safety notes
Extraction can stomp on files already sitting in your current directory. So check where you are with pwd before you run tar -x, or just unpack into a fresh folder with -C and skip the worry entirely. Running -t first tells you whether the archive opens into one tidy top-level folder or sprays files all over the place. And don’t unpack archives from people you don’t trust without looking first. A nasty one can hide absolute paths or ../ traversal that writes outside where you expect. GNU tar strips that stuff by default, but I wouldn’t bet older tools do.
Privacy and how this tool runs
JavaScript assembles the command from whatever you click, entirely in your browser. No server ever sees your filenames or paths, and nothing gets logged. If you’re skeptical, open devtools and watch the Network tab stay empty while you type.
Frequently asked questions
How do I extract a .tar.gz file?
Run tar -xzvf archive.tar.gz. The x extracts, z deals with gzip, v shows you each file, f points at the filename. Want it in a particular folder? Tack on -C /target/dir. And on a recent GNU tar you can drop the z altogether, since it figures out the format on its own.
What is the difference between -czf and -xzf?
It all hangs on the first letter. c makes a new archive, x pulls an existing one apart. After that they’re identical: z for gzip, f for the filename. Swapping those two letters is the classic tar slip-up, and probably the reason you’re here. So the generator just picks the right one and you stop thinking about it.
How do I create a tar.gz of a directory?
tar -czvf name.tar.gz folder/. Archive name goes straight after -f, the folder you’re packing goes last. Order matters here, don’t flip them. Want to leave stuff out? --exclude='*.log' skips matching files, and --exclude-vcs quietly drops .git and its friends.
Should I use gzip, xz or zstd?
gzip (-z) is the boring safe answer that works everywhere. xz (-J) gets you the smallest files for shipping, you just pay in time. zstd (–zstd) is the one I’d actually reach for when both ends support it, because it lands near gzip’s ratio while running several times faster. Honestly, for nightly backups I’d grab zstd, or gzip if the other box is ancient. For a public release tarball, xz.
What does strip-components do?
--strip-components=N peels off N leading path segments as it extracts. Say an archive stuffs everything inside project-1.0/. Extract with --strip-components=1 and that wrapper vanishes, so the files drop straight into your target directory instead of one level down. It does nothing on create or list, by the way, only on extract.
Why does tar say “Removing leading / from member names”?
Relax, nothing’s broken. When you archive an absolute path like /etc, GNU tar stores it as a relative path (etc) instead, so unpacking later can’t blow away the real system files in /etc. It’s a safety move. The message is just tar telling you it did it, and your archive is completely fine.
Sources & further reading
Related tools and resources
Archives sorted? Cron schedules and file permissions have the same flag problem, so I built the same kind of clicky fix for those too.













