How to open .tar.gz and other tar files on a Mac
Double-click the file: Archive Utility, built into macOS, unpacks .tar, .tar.gz, .tgz, .tar.bz2 and .tar.xz next to the archive. In Terminal, tar -xf file works for all of them, because the tar that ships with macOS detects the compression by itself.
A .tar.gz file is a bundle of files and folders (the tar part) squeezed by a compressor (the gz part). On a Mac, the quickest way to open one is to double-click it: Archive Utility, which is built into macOS, unpacks it into a folder next to the archive. The same goes for .tar, .tgz, .tar.bz2 and .tar.xz. If you prefer Terminal, tar -xf followed by the file name opens all of them, and if you want to see what’s inside before unpacking anything, you can open the archive in your browser.
What a .tar.gz file actually is
The name describes two steps.
- tar (from “tape archive”) joins many files and folders into one file. It doesn’t compress anything; it just lines the files up one after another, together with their names, folders, dates and Unix permissions. That’s why tar is the usual choice on Linux and macOS: an executable script stays executable after the trip.
- A compressor then shrinks that single file as a whole. The extension tells you which one was used.
| Extension | What it is | Where you’ll see it |
|---|---|---|
.tar |
Plain tar, no compression | Backups, files passed between systems |
.tar.gz, .tgz |
tar + gzip | Source code, software downloads, the most common kind |
.tar.bz2, .tbz2 |
tar + bzip2 | Older open-source releases; smaller than gzip, slower |
.tar.xz, .txz |
tar + xz | Linux software and large data sets; usually the smallest |
Because the compression covers the whole bundle rather than each file, a tool has to read through the archive from the start to reach a given file. Listing or extracting one file from a large .tar.xz can take as long as reading everything before it. ZIP works the other way round, compressing each file on its own; the comparison in RAR vs ZIP vs 7z goes into the trade-offs.
A file that ends in just .gz, without .tar, is a different thing: a single compressed file, not a bundle. How to open a .gz file covers those.
Double-click: Archive Utility
Archive Utility is the small app macOS uses to unpack archives. You never really open it yourself: you double-click the archive in Finder, and a folder with the contents appears beside it, in the same location.
- On current versions of macOS, Archive Utility handles all four kinds in the table above.
- If double-clicking opens the file in another app, Control-click it, choose Open With, then Archive Utility.
- Archive Utility doesn’t show you the contents first; it extracts everything. For a large archive where you need one file, Terminal or the browser is quicker.
There’s more about its settings, and what it can’t open, in Archive Utility on Mac.
Terminal: one command for every kind
The tar command that comes with macOS is bsdtar, built on the libarchive library. It recognises gzip, bzip2 and xz compression from the file’s content, so one command covers .tar, .tar.gz, .tgz, .tar.bz2 and .tar.xz:
cd ~/Downloads
tar -xf archive.tar.gz
The files land in the current folder, here Downloads. The letters mean: x extract, f the file that follows. A few useful variations:
tar -tf archive.tar.xz
lists the contents without extracting anything.
mkdir ~/Desktop/unpacked
tar -xvf archive.tar.bz2 -C ~/Desktop/unpacked
extracts into another folder (-C; the folder must already exist, hence the mkdir) and prints each file name as it goes (v).
You’ll still see tar -xzf in many instructions online. The z asks for gzip explicitly, and macOS accepts it, along with j for bzip2 and J for xz, but you don’t need them. A handy shortcut: type tar -xf with a space, then drag the archive from Finder into the Terminal window to paste its full path.
Two error messages you may meet:
- “Unrecognized archive format”: the file isn’t a tar archive at all, or it’s so damaged that tar can’t tell what it is. Check that the download finished and that the file is the size the website says.
- “truncated gzip input” (or a similar message for bzip2 or xz): the file stops early. That’s almost always an incomplete download; download it again.
If you’re new to Terminal, Open RAR files on Mac with Terminal explains the basics, such as moving between folders.
In your browser
openrar.app opens .tar, .tar.gz, .tgz, .tar.bz2 and .tar.xz right in the page. Drop the archive on the window and every file appears with its folder and size; save the files you need one by one, or everything as a single ZIP with Download all as ZIP. Nothing is uploaded: the extraction runs on your Mac, inside the browser.
This is useful when you:
- want to look inside before unpacking hundreds of files into your Downloads folder;
- need two files out of a large source archive;
- are on a Mac where you’d rather not use Terminal, or on someone else’s computer.
The browser has limits: archives up to about 2 GB on a computer, and about 2.5 GB once unpacked. For anything larger, Terminal is the better tool, as it streams the archive instead of holding it in memory.
Which method to use
| You want to… | Use |
|---|---|
| Just get the files out | Double-click (Archive Utility) |
| Extract into a specific folder, or script it | tar -xf … -C … in Terminal |
| See the contents first, or take only a few files | tar -tf, or openrar.app |
| Open an archive larger than about 2 GB | Terminal |
Making a .tar.gz on a Mac
Going the other way is one command too:
tar -czf project.tar.gz project
This packs the folder project into project.tar.gz (c create, z gzip). Use -cJf and a .tar.xz name for smaller files, at the cost of speed. For everyday sharing with people on Windows, a ZIP is often kinder; How to compress files on a Mac compares the options.