tar command generator
Build the exact tar command for creating, extracting or listing an archive without memorising the flag soup. Pick the operation, choose a compression format, tick the options you need and copy a command that runs as-is. Every flag is explained underneath so you learn what -czvf actually means. Nothing is uploaded; the command is assembled in your browser.
What this tar command generator does
The tar utility bundles many files into a single archive and, with a compression filter, shrinks it. Its power comes at the cost of a flag syntax that is famously hard to remember: the difference between -czf and -xzf is one letter that decides whether you create or extract. This generator lets you pick the operation and options in plain language and produces the precise command, so you copy something that works the first time instead of guessing and risking an overwrite.
The four core operations are mutually exclusive: create (-c) makes a new archive, extract (-x) unpacks one, list (-t) shows the contents without unpacking, and append (-r) adds files to an existing uncompressed archive. The -f flag always precedes the archive filename and the compression flag selects the filter: -z for gzip, -j for bzip2, -J for xz and --zstd for Zstandard.
How to read a tar command
A typical command such as tar -czvf backup.tar.gz /etc breaks down as create (c), gzip (z), verbose (v), file (f) named backup.tar.gz, containing /etc. The short flags can be bundled after a single dash, and f must come last in the bundle because the next argument is its value, the filename. Modern GNU tar can usually auto-detect the compression on extraction, so tar -xf archive.tar.gz works without -z, but being explicit keeps scripts portable to BSD tar.
- Create a gzip archive of a folder:
tar -czvf site.tar.gz public_html/ - Extract here:
tar -xzvf site.tar.gz - Extract into a target dir:
tar -xzvf site.tar.gz -C /var/www - List without extracting:
tar -tzvf site.tar.gz
Choosing a compression format
| Flag | Format | Trade-off |
|---|---|---|
-z | gzip | Fast, universal, moderate ratio. The safe default. |
-j | bzip2 | Smaller than gzip, noticeably slower. Legacy. |
-J | xz | Best ratio, slowest and most memory-hungry. Great for release tarballs. |
--zstd | Zstandard | gzip-class ratio at far higher speed. Modern default where available. |
Safety notes
Extraction can overwrite files in the current directory, so always know where you are with pwd before running tar -x, or extract into a fresh directory with -C. Listing first with -t shows whether an archive expands into a single top-level folder or scatters files into the current one. Avoid extracting archives from untrusted sources without inspecting them, because a maliciously crafted archive can contain absolute paths or ../ traversal; GNU tar strips these by default but older tools may not.
Privacy and how this tool runs
The command is assembled by JavaScript in your browser from the options you select. No file names, paths or commands are sent to a server, logged or stored. You can use the generator offline once the page has loaded.
Frequently asked questions
How do I extract a .tar.gz file?
Use tar -xzvf archive.tar.gz: x extracts, z handles gzip, v lists files, f names the file. To unpack into a specific folder add -C /target/dir. On modern GNU tar you can even omit the z because the format is auto-detected.
What is the difference between -czf and -xzf?
The first letter is the operation: c creates a new archive, x extracts an existing one. Both then use z for gzip and f for the filename. Mixing them up is the most common tar mistake, which is exactly why this generator picks the right one for you.
How do I create a tar.gz of a directory?
tar -czvf name.tar.gz folder/. The archive name comes right after -f, the folder to archive comes last. Add --exclude='*.log' to skip files or --exclude-vcs to drop .git and similar directories.
Should I use gzip, xz or zstd?
gzip (-z) is the universal safe choice. xz (-J) gives the smallest files for distribution at the cost of speed. zstd (–zstd) is the modern winner when both ends support it: near-gzip ratios at several times the speed. For nightly backups, zstd or gzip; for a public release tarball, xz.
What does strip-components do?
--strip-components=N removes N leading path segments on extraction. If an archive wraps everything in project-1.0/, extracting with --strip-components=1 drops that wrapper so the files land directly in the target directory. It only applies to extract operations.
Why does tar say “Removing leading / from member names”?
When you archive an absolute path like /etc, GNU tar stores it as a relative path (etc) so extraction cannot accidentally overwrite system files in the real /etc. This is a safety feature; the warning is informational and the archive is fine.
Related tools and resources
More command builders and Linux references from the same toolkit.













