The TAR.GZ (.tar.gz, .tgz) Format, Explained
iLoveConverter Team 3 min read
On this page
TAR.GZ — also written .tar.gz or .tgz — is not one format but two working together. A TAR archive bundles many files into a single stream, and gzip compresses that stream. The result is the standard way Unix and Linux users package source code, backups and log collections.
Two layers, two jobs
Understanding the name explains the behaviour:
- TAR — Tape ARchive. It concatenates files and directories into one long byte stream, recording names, permissions, timestamps and ownership in 512-byte headers. TAR itself does not compress anything.
- GZ — gzip. It compresses a single byte stream using DEFLATE. gzip has no concept of files or folders; it only sees bytes.
So tar creates the structure and gzip squeezes it. That is why you sometimes see .tar files that are huge and .gz files that hold exactly one file. Stack them and you get a portable, compressed bundle.
What is inside
A TAR.GZ begins with a gzip header, then the DEFLATE-compressed payload. Decompress it and you get a TAR stream:
- 512-byte blocks for each file header and its data, padded to the block size.
- A path name up to 100 characters in the classic header; longer names use PAX or GNU extensions.
- Permissions, owner IDs, timestamps — Unix metadata that ZIP often loses or stores differently.
- A directory tree expressed as a sequence of entries, not a central index.
One consequence: to list the contents of a TAR.GZ, a tool must decompress the stream from the start. ZIP, by contrast, keeps a central directory at the end, so listing is instant. Streaming is TAR’s strength; random access is its weakness.
Where TAR.GZ is used
- Source code releases. Most open-source projects publish
.tar.gztarballs. - Linux backups.
tar -czfis the default reflex for archiving a directory. - Server logs. Compressing rotated logs saves substantial disk space.
- Data pipelines. TAR.GZ streams can be piped through tools without writing an intermediate file.
TAR.GZ vs ZIP
| Aspect | TAR.GZ | ZIP |
|---|---|---|
| Compression | Whole stream via gzip | Per-file, DEFLATE or others |
| Random access | Poor, sequential | Good, central directory |
| Unix permissions | Preserved | Limited, varies by tool |
| Windows support | Needs a tool (7-Zip, WinRAR) | Built in |
| Partial extraction | Requires decompressing up to the file | Can extract one file quickly |
| Typical use | Source, Linux backups | Cross-platform sharing |
Because gzip compresses the whole stream, a single damaged byte can make later content unrecoverable. ZIP’s per-file structure limits damage to one entry. That is a real trade-off when archiving important data.
Creating and extracting
On Linux or macOS:
tar -czf archive.tar.gz folder/
tar -xzf archive.tar.gz
The z flag invokes gzip. On Windows, 7-Zip and WinRAR open TAR.GZ directly. If a tool only understands one layer, decompress the .gz first to get a .tar, then extract the TAR.
When to convert TAR.GZ to ZIP
ZIP is the safer choice when the recipient is on Windows or when you need to pull out a single file without unpacking everything. Converting means decompressing the TAR.GZ and repacking the contents as ZIP. File contents are unchanged; only the container and compression method differ. If the archive contains Unix symlinks or special permissions, check that the ZIP tool preserves them — many do not.
Common problems
- “Not in gzip format” — the file may be a plain TAR renamed to
.gz. - Truncated archive — an interrupted download leaves a gzip stream that ends early; re-download rather than trying to repair.
- Path traversal warnings — archives containing
../paths are a security risk; modern extractors block them.
FAQ
Is TAR.GZ the same as TGZ?
Yes. .tgz is a short alias for .tar.gz, created because old filesystems limited extensions to three characters.
Does TAR.GZ compress better than ZIP?
Usually slightly better, because gzip sees the whole stream and can exploit repetition across files. The difference is small for mixed data and larger for repetitive text.
Can I open TAR.GZ on Windows?
Yes, with 7-Zip, WinRAR or PeaZip. Windows Explorer does not open it natively without additional software.
Is TAR.GZ lossless?
Yes. Both TAR and gzip are lossless; extracting restores the original bytes exactly.
Try it yourself — free, right in your browser
Everything mentioned in this guide runs locally on this site: no upload, no watermark, no sign-up.
Format deep-dives: TAR.GZ (.tar.gz.tgz) , TAR (.tar) , GZ (.gz)