How to open tar.gz, tar.xz, and tar.zst files on a Mac
A .tar file bundles many files into one; the second extension says how that
bundle was compressed. macOS handles most of them on its own:
| File | Double-click (Archive Utility) | Terminal | Purrchiver |
|---|---|---|---|
.tar, .tar.gz, .tgz | Opens | tar -xf file.tar.gz | Opens free |
.tar.bz2 | Opens | tar -xf file.tar.bz2 | Opens free |
.tar.xz | Opens | tar -xf file.tar.xz | Opens free |
.tar.zst | Doesn’t open | Needs zstd installed (below) | Opens free |
.tar.lz | Doesn’t open | tar -xf file.tar.lz | Opens free |
.tar.lz4 | Doesn’t open | Needs lz4 installed | Opens free |
.tar.br | Doesn’t open | brotli -dc file.tar.br | tar -xf - | Opens free |
tar -xf works out the compression by itself, so you don’t need to remember
separate flags. It extracts into the current folder; add -C ~/Desktop to
extract somewhere else.
Opening a .tar.zst
.tar.zst is a tar compressed with Zstandard, common for software downloads
and backups. Archive Utility doesn’t support it, and the tar built into
macOS can only open it if the separate zstd program is installed. Without
it, tar fails with:
tar: Error opening archive: Can't initialize filter; unable to run program "zstd -d -qq"Two fixes:
- Terminal: install
zstdwith Homebrew (brew install zstd). After that,tar -xf file.tar.zstjust works. - An app: Purrchiver opens
.tar.zstfree, and Keka opens Zstandard archives too. See Purrchiver vs Keka.
A .tar.zst.age file is a .tar.zst that’s also encrypted: see
age encryption on macOS.
Taking out one file
Archive Utility always expands the whole archive. To take out one file:
Terminal: list the contents, then name the file you want:
tar -tf file.tar.gz tar -xf file.tar.gz path/inside/file.txtIt’s created at the same path inside the current folder.
Purrchiver: open the archive, find the file, and drag it out, or press Space to preview it first.
Making them
Finder’s Compress only makes ZIP. tar -czf out.tar.gz folder makes a
.tar.gz for free. Purrchiver makes .tar.gz and .tar.bz2 free, and
.tar.xz, .tar.zst, and the others with its one-time unlock. For how they
compare on speed and size, see
Zstandard, Brotli, LZ4 and lzip on macOS and the
benchmarks.