DevTools Logo

Tar Command Builder

Tar Command Builder

Assemble a valid tar command — create, extract, list or append — with every flag explained.

Runs in your browser
Try an example

Command options

Suggested extension: .tar.gz

Generated command

3 flags
tar czf archive.tar.gz dist/
FlagMeaning
-ccreate (c = C)
-zgzip compression
-fthe next argument is the archive filename (f must be last in the flag cluster)

Tar Command Builder assembles a valid GNU tar invocation from an operation, compression format, archive name, source paths, exclude patterns and options. The compressed flag cluster ends with f immediately before the archive filename, so the command cannot be misordered. Each flag is explained next to the command, and incompatible combinations such as appending to a compressed archive, absolute source paths or zstd on BSD tar are called out as warnings.

Release tarball
tar czvf release.tar.gz --exclude='*.map' dist/ README.md

Create a gzip archive with verbose output and an exclude pattern; c is create, z is gzip, v is verbose and f precedes the filename.

Extract to a directory
tar xzf release.tar.gz -C out

The -C option changes directory before extraction; the target directory must already exist.

List without extracting
tar tzf release.tar.gz

t lists archive members; keep the compression flag so tar can read the stream.

Examples

czf

Input
create + gzip + release.tar.gz + dist/
Output
tar czf release.tar.gz dist/

c creates, z compresses with gzip and f introduces the archive name.

xzf with -C

Input
extract + gzip + -C out
Output
tar xzf release.tar.gz -C out

x extracts and -C requires an existing destination directory.

Compressed append

Input
append + gzip
Output
warning: cannot append to a compressed archive

GNU tar cannot append to gzip streams; create a new archive or drop compression.

About this tool

Tar Command Builder turns a small form into a correct tar command. Choose create, extract, list, append or update; pick none, gzip, bzip2, xz or zstd compression; then add the archive name, source paths and any exclude patterns.

The builder places the f flag last in the short cluster so the archive filename always follows it, and it explains every emitted flag in a companion table. Warnings call out the classic traps: appending to a compressed archive, absolute source paths, zstd on BSD tar and -C during archive creation.

Presets for a release tarball, extraction into a directory, an excluded backup and a compressed-append mistake make the common cases discoverable. Commands are generated locally; nothing about your paths is uploaded.

What this tool does not do

  • Commands target GNU tar conventions; some long flags differ on BSD/macOS tar.
  • The builder does not execute commands or validate that archive names exist on disk.
  • Shell quoting follows POSIX single-quote rules and is not tailored to PowerShell or cmd.exe.
  • Zstd support depends on the local tar build; a warning is shown but capability is not probed.
  • No options or paths are uploaded or persisted between visits.

How to use this tool

  1. Choose an operation

    Create (c), extract (x), list (t), append (r) or update (u) sets the first flag.

  2. Pick compression

    None, gzip (-z), bzip2 (-j), xz (-J) or zstd (--zstd); the suggested archive extension updates with your choice.

  3. Add paths and excludes

    Enter one source path and one exclude pattern per line. Paths with spaces are shell-quoted automatically.

  4. Set options

    Verbose, keep-old-files and preserve-permissions add -v, -k and -p; -C changes directory before the operation.

  5. Copy the command

    The generated command and its flag explanations update on every change; copy or download when it looks right.

Use cases

Release packaging

Build a reproducible tarball command with excludes and verbose output.

Restore drills

Generate an extraction command with the right decompression flag and target directory.

Cheat-sheet replacement

Learn what each flag does while assembling a real command instead of scanning a table.

CI scripts

Copy the exact command into a pipeline step and share the flag explanation with reviewers.

Flag clusters

ClusterMeaning
c / x / t / r / uCreate, extract, list, append or update an archive
z / j / J / --zstdgzip, bzip2, xz or zstd compression
v / k / pVerbose, keep old files, preserve permissions
fAlways last in the cluster; the next argument is the archive filename
-C dirChange to dir before processing the remaining paths
--exclude=PATTERNSkip matching paths; place before source paths

The builder always emits -f last so czf and xzf read naturally and behave predictably.

Common mistakes

Mistake:Putting f before other flags or far from the archive name.

Fix:The builder keeps f last in the cluster and places the filename immediately after it.

Mistake:Appending or updating a .tar.gz in place.

Fix:Remove compression or create a fresh archive; the tool warns on this combination.

Mistake:Using zstd flags with BSD tar on macOS.

Fix:The zstd preset warns that GNU tar 1.31+ is required.

Mistake:Quoting paths with spaces by hand and getting shell escaping wrong.

Fix:The builder applies shell quoting, including embedded single quotes, for you.

Mistake:Assuming -C creates the destination directory.

Fix:Create the directory first; the builder notes this on extraction commands.

Frequently asked questions

What does czf mean in tar?

It is a cluster of three short flags: c creates a new archive, z compresses it with gzip, and f says the next argument is the archive filename. Because f takes an argument, it is always placed last in the cluster.

Why must f come right before the filename?

tar reads the token immediately following the f flag as the archive name. Putting other options in between makes tar treat an option as the filename. The builder enforces f-last ordering structurally, so the generated command stays correct.

What is the difference between z, j, J and --zstd?

z selects gzip (.tar.gz), j selects bzip2 (.tar.bz2), J selects xz (.tar.xz), and --zstd selects zstd (.tar.zst). The right decompression flag must be used on listing and extraction too; the auto-suggested extension changes with your choice.

How do I extract to a specific directory?

Choose Extract, set Compression to match the archive, and fill the Change directory field, for example `tar xzf release.tar.gz -C out`. The destination directory must already exist.

Can tar exclude files?

Yes. Add one glob per line in the Exclude patterns field; the builder emits --exclude=PATTERN before the source paths. Patterns are shell-quoted when they contain special characters.

Can I append to a compressed archive?

No. GNU tar cannot append to gzip, bzip2, xz or zstd streams. The compressed append example demonstrates the warning; create a new archive or use an uncompressed .tar if you need incremental updates.

References & standards