tar Command Generator

Build, extract or list any tar archive by clicking, with every flag explained.

This tar command generator builds the exact tar invocation you need without forcing you to memorise the flag soup that makes -czf and -xzf one slip away from disaster. Pick an operation (create, extract, list or append), choose a compression filter (gzip, bzip2, xz or zstd), tick the options you actually want, and copy a command that runs as-is. Every flag in the result is broken down in plain English underneath, so you finally learn what -czvf means instead of pasting it on faith. Handy presets cover the everyday jobs: gzip a folder, extract into a target directory, list contents, or max-compress a release tarball. Nothing is uploaded; the command is assembled entirely in your browser.

100% in your browser. Nothing you type ever leaves this page.

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 command generator turns a few clicks into the precise tar invocation you need, because 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. Pick the operation and options in plain language and the tool produces the exact 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

  • -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 parent-directory traversal; GNU tar strips these by default but older tools may not. The command itself is assembled by JavaScript in your browser, so no file names, paths or commands are sent to a server.

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?

Run tar -czvf name.tar.gz folder/. The archive name comes right after -f and the folder to archive comes last. Add --exclude 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 reach for zstd or gzip, and for a public release tarball reach for xz.