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

A .tgz file is a compressed archive that bundles multiple files and folders into one smaller package. The name comes from two compression methods stacked together: tar (which packages files) and gzip (which compresses them). You'll see .tgz files when downloading software, backups, or source code, especially from open-source projects.

To use what's inside, you have to extract it first — that means unpacking the compressed archive back into individual files and folders. The steps differ slightly depending on whether you're on Windows, Mac, or Linux, but the concept is the same on all three.

Key Takeaways

  • Mac and Linux have built-in tools to extract .tgz files; Windows requires either a third-party program like 7-Zip or using Windows Subsystem for Linux.
  • Right-clicking a .tgz file and selecting "Extract" works on Mac and newer Windows versions with the right software installed.
  • The command line method tar -xzf filename.tgz works identically on Mac and Linux and is the fastest route if you're comfortable typing commands.
  • After extraction, you'll have a folder with the same name as the .tgz file (minus the .tgz part) in the same location where the archive was.
  • If extraction fails, check that the file downloaded completely and that you have the right tool installed for your operating system.

Extracting on Mac

Mac includes the tools to extract .tgz files without installing anything extra. The easiest method is to double-click the .tgz file in Finder. macOS will automatically extract it, and a new folder will appear in the same location within a few seconds.

If double-clicking doesn't work, or if you want to extract from the command line, open Terminal (find it in Applications > Utilities > Terminal). Navigate to the folder where your .tgz file is located by typing cd /path/to/folder, then type tar -xzf filename.tgz and press Enter. Replace "filename" with the actual name of your file. The extracted folder will appear in that same directory.

Extracting on Linux

Linux has tar and gzip built in, so extraction is always done through the terminal. Open a terminal window, navigate to the folder containing your .tgz file, and type tar -xzf filename.tgz. Press Enter and wait for the command to finish — there's usually no confirmation message, just a return to the command prompt.

If you want to extract the files to a different folder than where the .tgz file is, add -C /path/to/destination to the end of the command. For example: tar -xzf filename.tgz -C ~/Downloads will extract into your Downloads folder instead.

Extracting on Windows

Windows does not have native .tgz support, so you'll need either a third-party program or to use Windows Subsystem for Linux. The easiest route for most people is to install 7-Zip, which is free and handles .tgz files without any setup. Download it from 7-zip.org, install it, then right-click your .tgz file and select "7-Zip > Extract Here." A folder will appear in the same location.

If you prefer not to install software, Windows 10 and later can use Windows Subsystem for Linux (WSL). This is more complex to set up but gives you the same command-line tools as Linux. Once WSL is installed, you can use the same tar -xzf filename.tgz command. If you're not already using WSL, 7-Zip is the faster choice.

Another option is to use the free program PeaZip, which works similarly to 7-Zip. Both are reliable and don't require a subscription or special configuration.

What to do if extraction fails

If you get an error message or the extraction doesn't produce any files, the most common cause is an incomplete download. Check the file size against what the website said it should be. If the sizes don't match, download it again.

On Windows, if you see an error like "not a valid archive," you probably don't have the right extraction tool installed. Download and install 7-Zip or PeaZip, then try again. On Mac or Linux, if the command line returns an error, double-check that you typed the filename exactly right — including capitalization and the .tgz extension.

If the file is corrupted and won't extract no matter what you try, go back to where you downloaded it and download a fresh copy. Corruption during download is rare but does happen, especially on slow or interrupted connections.

Understanding what's inside after extraction

Once extraction finishes, you'll see a new folder (usually with the same name as the .tgz file, but without the .tgz part). Open it to see the files and folders that were compressed inside. The structure is preserved exactly as it was — if there were subfolders, they'll still be there.

Some .tgz files contain source code that needs to be compiled, others contain ready-to-use programs, and some are just backups of documents. Check the README file or documentation that came with the download to understand what to do next. You can now delete the original .tgz file if you want to save space — you have the extracted version.

Frequently Asked Questions

Can I open a .tgz file without extracting it?

No, you have to extract it first. Some archive managers let you preview files inside without fully extracting, but to actually use the files, extraction is required. The extraction process is fast and doesn't harm the original .tgz file.

What's the difference between .tgz and .tar.gz?

.tgz and .tar.gz are the same thing — just two different ways of writing the filename. Both mean a tar archive that's been compressed with gzip. Your extraction method doesn't change based on which name is used.

Do I need to keep the .tgz file after I extract it?

No. Once you've extracted it and confirmed the files are there, you can delete the .tgz file. It's just a container. Keep it only if you think you might need to extract it again later or if you want a backup copy of the original compressed version.

Why does my extracted folder have a weird name or structure?

The folder name and internal structure come from how the person who created the .tgz file organized it. You can rename the extracted folder to anything you want. If the internal structure seems odd, check the documentation that came with the download — it will explain what each folder is for.

Can I extract just one file from a .tgz instead of everything?

On Mac and Linux, yes — use the command tar -xzf filename.tgz path/to/specific/file. On Windows with 7-Zip, you can open the .tgz file like a folder, find the file you want, and drag it out. Most of the time though, it's simpler to just extract everything.