Tar Command Decoder and Builder

The cryptic flags, in plain English.

Paste a tar command and read what every flag does, with warnings for the mistakes that bite: -C in the wrong place, an archive accidentally named "v", excludes that exclude nothing, and extractions that overwrite. Or tick what you want and copy a command that is right the first time.

Zero retention: your data never leaves this browser. Verify it yourself in DevTools

Loading the toolbox.

About tar

How Can You Verify That Nothing Leaves This Browser?

You do not have to take our word that your data stays here. Developer tools show every request a page makes, so you can watch this page work and confirm that nothing is sent. The check takes under a minute.

  1. Open your browser developer tools with F12, or Cmd+Option+I on a Mac, and select the Network tab.
  2. Reload the page and let it finish. You will see the page's own files, its web fonts, and one anonymous page-view request. Nothing has been typed yet, so none of them can contain your data.
  3. Click the clear icon in the Network tab so that the log is empty.
  4. Use the tool with your own input.
  5. Look at the Network tab again. It is still empty. For extra proof, turn on offline mode after the page loads and the tool keeps working.

Only two things can add a line to that log, and neither carries your data. Submitting the feedback form sends the vote and comment you typed. Typing characters in a script the page has not displayed yet, such as Cyrillic or Greek, can make the browser fetch the matching font file, and that request names only the font.

The production site also sends a Content-Security-Policy header that tells your browser to refuse connections to anywhere except this site and the anonymous analytics endpoint, so a coding mistake could not quietly send your data elsewhere.

Why Are tar Flags So Confusing?

tar dates from the days of tape drives, and its options show it. Single letters are bundled together, so -xzvf is four options. The oldest form drops the dash entirely, as in tar xzvf. Some letters take a value and some do not, and a few options change meaning depending on where they appear on the line. Two different programs also answer to the name: GNU tar on most Linux systems, and bsdtar from libarchive on macOS, the BSDs, and Windows 10 and later.

This page reads a command the way tar does and writes out each part in plain English, so you can see what a command from a tutorial, a README, or your shell history will really do before you run it.

What Is the -C Ordering Trap?

The -C option changes directory, but only for the file names that come after it. When you create an archive, tar -czf site.tar.gz -C /var/www html reads html from /var/www and stores it as html/. Move -C to the end, as in tar -czf site.tar.gz html -C /var/www, and tar reads html from the current folder instead, and the -C changes nothing. GNU tar prints a warning about options used after the file names, but the archive is still written, often with the wrong contents.

The same rule applies to --exclude in GNU tar 1.29 and later: an exclude placed after the paths applies to nothing, so the node_modules folder you meant to skip ends up in the archive. bsdtar applies excludes wherever they appear, which is why a command can work on a Mac and fail on a Linux server. The decoder flags both cases and tells you where to move the option.

Which Other Mistakes Does It Catch?

  • An archive named "v": in tar -cfv backup.tar dir, the f takes the rest of its bundle as the archive name, so the archive is called v and backup.tar is added to it. Put f last, as in -cvf.
  • No mode, or two modes: tar needs exactly one of create, extract, list, append, or update, and refuses to run otherwise.
  • Compression that does not match the name: -z with a file named .tar.bz2 makes a gzip file with the wrong extension. The -a option picks the compressor from the name for you.
  • Conflicting compression: -z and -j together are an error.
  • Unknown options: a typo or a GNU-only option such as --transform or --remove-files that bsdtar on macOS does not have.
  • Wildcards on extract: GNU tar does not treat member names as patterns unless you add --wildcards, and an unquoted pattern is expanded by your shell first.
  • Archiving the current folder into itself: writing the archive into the folder you are archiving can make tar try to add the archive to itself.

Which tar Options Are Destructive?

Most tar commands only read files, but a few can destroy data, and the decoder marks them in red:

  • --remove-files deletes each source file after adding it to the archive. If the archive is damaged, the files are gone.
  • --overwrite and -U replace existing files on disk without asking.
  • -P keeps absolute paths, so extracting can write anywhere, including system folders.
  • -C / on extract unpacks everything relative to the filesystem root.
  • --delete rewrites an archive in place and removes members permanently.

Plain extraction also replaces existing files with the same names, which surprises many people. Add -k to keep existing files or --keep-newer-files to keep files that are newer than the archive copy.

How Do You Extract Safely?

  1. List the archive first with tar -tvf archive.tar.gz and check that everything sits under one top-level folder, with no absolute paths and no ../ paths.
  2. Make an empty folder with mkdir -p restore, because -C does not create its target.
  3. Extract into it with tar -xf archive.tar.gz -C restore. No -z is needed: both GNU tar and bsdtar detect gzip, bzip2, xz, and zstd when reading a file.
  4. Use --strip-components=1 when you want the contents of the top-level folder without the folder itself.

An archive that spills dozens of files into the current folder is called a tarbomb, and listing first is the simple defense. Avoid extracting archives from strangers with sudo, because as root tar restores the owners and permissions stored in the archive.

How Does the Command Builder Work?

Choose whether you want to create an archive, extract one, or list its contents, then tick what you need: compression, verbose output, a folder to read from or extract into, exclude patterns, stripped folders, and whether to keep existing files. The builder writes the flags in a safe order: the f letter last in its bundle, excludes before the paths, and -C before the names it should apply to. Every part of the result is explained, and any part can be sent back to the decoder with one click.

Changing the compression also updates the file extension, so a gzip archive ends in .tar.gz and a zstd archive ends in .tar.zst. zstd uses the long option --zstd, which needs GNU tar 1.31 or later, or bsdtar 3.3 or later.

Which Recipes Are Included?

The recipe panel covers the jobs people search for most often: create a .tar.gz of a folder, list an archive, extract into a folder, extract a single file, drop the top-level folder, exclude node_modules and log files, archive a folder without its parent path, make the smallest archive with xz, use zstd, copy a folder over SSH with a tar pipe, archive files from a find list, and build a reproducible archive with GNU tar. Each recipe opens in the decoder, so you can see why it works before copying it. Other command builders sit in the same lane, such as ffmpeg for video and audio and Git commands for undoing mistakes.

What Other Tools Are in the Commands Lane?

  • ffmpeg: Pick a task to get an explained ffmpeg command, decode a pasted one, or work out the bitrate for a target file size.
  • Git commands: Describe what you want to do in git, from undoing a commit to recovering a deleted branch, and get the command with a danger badge.
  • OpenSSL: Explained OpenSSL commands for keys and CSRs with SANs, self-signed certificates, inspection, PEM, PFX, and DER conversion, and chain checks.
  • systemd: Generate a systemd service and timer with restart, user, environment, and hardening options, convert cron to OnCalendar, and copy the install commands.
  • Dockerfile: Generate a multi-stage Dockerfile for Node, Python, static sites, or Go with a non-root user and healthcheck, plus a .dockerignore and a paste linter.

Elsewhere in the toolbox: UUID, .gitignore, CSP, .htaccess, and more on the 2toolbox home page. Part of the 2suite.io privacy-first ecosystem.

Frequently Asked Questions

What does tar -xzvf mean?

x extracts, z uses gzip, v prints each file name, and f says the next word is the archive file. On extract the z is optional, because tar detects the compression itself.

Why did tar ignore my -C option?

When creating an archive, -C only applies to file names that come after it. Put -C and its folder before the names you want read from that folder.

Why did tar make a file called v?

In a bundle such as -cfv, the f takes the rest of the bundle as the archive name. Put f last, as in -cvf, so the next word is used as the name.

Is the tar on macOS the same as on Linux?

No. macOS ships bsdtar from libarchive and most Linux systems ship GNU tar. Common flags match, but some options, such as --transform, --remove-files, and --wildcards, exist only in GNU tar.

Does this page run my command?

No. The command is only parsed in your browser and never run or sent anywhere. Copy it and run it in your own terminal.

Was this helpful?