What a tar.gz file is and why you need to extract it

A tar.gz file is a compressed archive — a single file that holds many files and folders bundled together and squeezed down in size. The ".tar" part means the files are bundled, and the ".gz" part means they're compressed. You'll see these files most often when downloading software source code, backups, or large collections of files from the internet.

To use what's inside, you need to extract (or "untar") the archive. This reverses the bundling and compression, giving you back the original files and folder structure. The process is straightforward on Mac and Linux, and only slightly more involved on Windows. Once extracted, you can open, edit, or run the files like any others on your computer.

Key Takeaways

  • On Mac and Linux, open Terminal, navigate to the folder holding the tar.gz file, and run tar -xzf filename.tar.gz to extract everything.
  • On Windows 10 and later, you can use the built-in tar command in PowerShell the same way as Mac and Linux.
  • On older Windows versions, download 7-Zip (free software) and right-click the tar.gz file to extract it.
  • The extracted files appear in the same folder as the tar.gz file unless you specify a different destination.
  • You can list what's inside a tar.gz file before extracting by using the -t flag instead of -x.

Extracting on Mac and Linux using Terminal

Open Terminal (on Mac, search for it in Spotlight; on Linux, right-click the desktop or use your application menu). Navigate to the folder where your tar.gz file is located. If the file is on your Desktop, type cd Desktop and press Enter.

Once you're in the right folder, type this command and press Enter:

tar -xzf filename.tar.gz

Replace "filename" with the actual name of your file. The flags mean: -x extracts, -z handles the gzip compression, and -f tells tar to work with a file. The extracted files will appear in the same folder. If you want them to go into a new subfolder instead, add -C foldername before the filename.

Extracting on Windows 10 and later

Windows 10 and later include tar support built into PowerShell. Right-click the Start button and select "Windows PowerShell" or "Terminal" (depending on your version). Navigate to the folder holding your tar.gz file using cd commands, just as you would on Mac or Linux.

Then run the same command:

tar -xzf filename.tar.gz

The extracted files appear in the same location. If PowerShell doesn't recognize the tar command, your Windows version may be older than version 10 — use the 7-Zip method instead. This built-in support means you don't need to download any extra software on newer Windows machines.

Extracting on older Windows versions with 7-Zip

Download 7-Zip from its official website (7-zip.org). It's free and has no ads or bundled software. Install it, then right-click your tar.gz file. You'll see a "7-Zip" menu option. Click it, then select "Extract Here" to unpack the files into the current folder, or "Extract to [foldername]" to create a new folder for them.

7-Zip will extract the tar.gz in two steps: first to a .tar file, then to the final files. This happens automatically and you'll see both stages in the folder. You can delete the .tar file once extraction is complete. The process takes only a few seconds for most files.

Checking what's inside before extracting

If you want to see what files are in the archive before extracting everything, use this command on Mac, Linux, or Windows 10+:

tar -tzf filename.tar.gz

This lists all the files without extracting them. The -t flag means "list contents" instead of extracting. This is useful if you're not sure whether the archive will create a single folder or scatter files everywhere. The output shows the full path of each file, which helps you understand the structure you'll get after extraction.

Troubleshooting common problems

If you see "file not found" or "cannot open," make sure you're in the correct folder and that you've typed the filename exactly right, including capitalization. On Windows, if you're not sure of the exact name, type the first few letters and press Tab — PowerShell will auto-complete it.

If the extraction seems to do nothing, check whether a folder with the extracted contents was created in the same location. Sometimes the archive unpacks into a subfolder rather than scattering files everywhere. If you still see no results, the file may be corrupted or not actually a tar.gz file — try opening it with 7-Zip on Windows or Archive Utility on Mac to see if you get an error message.

Frequently Asked Questions

What's the difference between tar, tar.gz, and tar.bz2?

All three bundle files together. The .tar uses no compression, so the file stays large. The .tar.gz uses gzip compression (smaller file, slower to extract). The .tar.bz2 uses bzip2 compression (even smaller, slower still). To extract .tar.bz2, replace the -z flag with -j in the tar command.

Can I extract just one file from the archive instead of everything?

Yes. Use tar -xzf filename.tar.gz path/to/specific/file, replacing the path with the file you want. You can find the exact path by listing the contents first with the -t command shown above.

Where do the extracted files go?

They go into the same folder as the tar.gz file, preserving the folder structure from inside the archive. If the archive contains a top-level folder, all files end up inside it. If not, files scatter into your current directory.

Do I need to delete the tar.gz file after extracting?

No, but you can if you want to save space. The tar.gz file and the extracted files are separate — deleting one doesn't affect the other. Keep the archive if you might need to extract it again or share it with someone else.