Skip to main content
coreydaley.dev

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:

FileDouble-click (Archive Utility)TerminalPurrchiver
.tar, .tar.gz, .tgzOpenstar -xf file.tar.gzOpens free
.tar.bz2Openstar -xf file.tar.bz2Opens free
.tar.xzOpenstar -xf file.tar.xzOpens free
.tar.zstDoesn’t openNeeds zstd installed (below)Opens free
.tar.lzDoesn’t opentar -xf file.tar.lzOpens free
.tar.lz4Doesn’t openNeeds lz4 installedOpens free
.tar.brDoesn’t openbrotli -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 zstd with Homebrew (brew install zstd). After that, tar -xf file.tar.zst just works.
  • An app: Purrchiver opens .tar.zst free, 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.txt

    It’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.

Download on the Mac App Store

Free forever to open and extract anything. $9.99 once for the advanced tools. No trial, no subscription.