Skip to content
gohacks.dev
Tooling

tar Command Builder

Build tar commands to create, extract or list archives with gzip, zstd, xz or bzip2, excludes, a target directory and stripped path components.

Free · No sign-up · Your inputs stay in your browser

Input

Build a tar command

Output

tar command

Command

tar -czvf backup-2026-10-13.tar.gz --exclude=node_modules --exclude=vendor --exclude='*.log' -C /var/www app/ .env

GNU tar and the bsdtar on macOS both detect compression when extracting, so -xf alone works for any of these; it is only needed when creating. --exclude must come before the paths in GNU tar. Extracting an archive you did not make? List it first: a path with ../ can write outside the target directory.

Runs in this browser. Nothing you paste is sent to a server.

Remembering the letters

c creates, x extracts, t lists, f names the archive and v prints each file. z is gzip, J is xz and j is bzip2; zstd has only the long option --zstd in GNU tar 1.31 and later. When extracting, GNU tar and bsdtar detect the compression themselves, so tar -xf archive works for all of them. See the GNU tar manual.

Relative paths

Creating with -C /var/www app/ stores app/... rather than /var/www/app/..., so the archive extracts wherever you choose. Before extracting an archive from elsewhere, list it with tar -tf: entries starting with / or containing ../ can write outside the target directory.

Share

Frequently asked questions

How do I extract a .tar.gz into a specific directory?
tar -xzf archive.tar.gz -C /target/dir. The directory must already exist.
Which compression should I use?
zstd compresses and decompresses fastest at a ratio close to gzip or better; xz gives the smallest files and is the slowest; gzip is readable everywhere.
Is what I paste sent anywhere?
No. The tool runs entirely in your browser with JavaScript. Nothing you type or paste is sent to our server or stored.

Keep planning

Similar tools