What is TGZ? The tar.gz Compressed Archive Format Explained
A gzip-compressed tar archive that bundles files and then shrinks them in one stream.
Last updated:
What is TGZ?
TGZ, also written as .tar.gz, is a compound format in which files are first combined into a single tar archive and that archive is then compressed with gzip. The result is one file that preserves Unix file structure and metadata while reducing size.
The two stages are separate: tar handles bundling and metadata such as permissions and timestamps, while gzip applies DEFLATE compression to the whole tarball. The .tgz extension is simply a shorthand for .tar.gz, and the file is decompressed by gunzip and then unpacked by tar.
How TGZ Works
Creating a .tar.gz is a two-stage pipeline. First, tar concatenates files into a single stream, prefixing each with a 512-byte header recording its name, permissions, ownership, and timestamps.[4] Then gzip compresses that entire tarball as one continuous stream using the DEFLATE algorithm, wrapped in the gzip header and trailer.[1]
Why Bundle Before Compressing
Because gzip operates on a single byte stream rather than a set of files, the tar step is what allows many files to be stored together; compressing the combined archive also lets DEFLATE exploit redundancy across file boundaries.[3] The GNU tar tool can invoke gzip automatically through its -z option.[2]
Technical Details and Limitations
Solid, whole-archive compression means there is no central index, so extracting one file generally requires decompressing the stream up to that point.[1] A corrupted region can also render the remainder of the archive unrecoverable, since gzip lacks per-file recovery records.[3]
MKV Technical Specifications
TGZ vs Other Archive Formats
| Feature | TGZ | ZIP | TAR |
|---|---|---|---|
| Structure | TAR + gzip[2] | Single container | Bundle only |
| Compression | gzip / DEFLATE[1] | DEFLATE | None |
| Per-file access | No[3] | Yes | Yes |
| Preserves Unix metadata | Yes | Limited | Yes |
| Best for | Unix source/release tarballs | Cross-platform sharing | Bundling only |
TGZ compresses an entire TAR stream as a whole, so unlike ZIP it cannot extract a single file without decompressing the archive.
Advantages & Disadvantages
Advantages
The tar layer keeps permissions, ownership, symlinks, and timestamps intact through compression.
Because gzip compresses the entire tarball as one stream, cross-file redundancy improves the overall ratio.
tar and gzip are standard on virtually every Unix and Linux system, requiring no extra software.
Archives can be created and extracted on the fly through pipes, ideal for backups and network transfer.
Disadvantages
Because the whole archive is a single compressed stream, individual files cannot be extracted without reading from the start.
Neither tar nor gzip provides encryption, so security must be added with separate tools.
Corruption early in the gzip stream can make the remainder of the archive unrecoverable.
Common Use Cases
TGZ is a default choice for packaging and moving files in Unix-like environments.
Source code distribution | FileFormer
Open-source projects commonly release source tarballs as .tar.gz downloads.
Backups | FileFormer
System administrators archive directory trees into compressed tarballs for storage and transfer.
Software packaging | FileFormer
Many Unix software bundles and language package ecosystems ship artifacts as tgz files.
Convert TGZ Files Free
Use our free online archive converter to convert TGZ and other formats - no signup, no watermarks.
Try Archive Converter FreeFrequently Asked Questions
What is the difference between tar and tgz?
A .tar file is an uncompressed archive, while a .tgz (or .tar.gz) is that same tar archive compressed with gzip.
How do I extract a tgz file?
Use 'tar -xzf archive.tgz', where the z flag tells tar to run the data through gzip during extraction.
Is tgz the same as tar.gz?
Yes. The .tgz extension is just a shorter way of writing .tar.gz.
Why use tgz instead of zip?
tgz preserves Unix file metadata and compresses the whole archive as one stream, which often yields smaller results for many small files.
Can I extract a single file from a tgz?
You can name a specific file, but tar must still read through the gzip stream to reach it because the format has no random-access index.