What is GZ (Gzip)?

Discover what GZ (Gzip) files are, how they function, and when to use them. This complete guide covers GZ format details without upload or signup.

Free online file converter tool. Works in Chrome Firefox Safari Edge Opera and other modern browsers on Windows macOS Linux Android and iOS. No software installation or sign-up required. All conversions run directly in your browser, so your files never leave your device. Free to use with no account needed.

GZ

What is GZ (Gzip)?

Complete guide to the GZ file format

Last updated:

Created1992
TypeArchive
Common UseLinux file compression

What is GZ (Gzip)?

GZ (Gzip) is a file compression format and software program created by Jean-loup Gailly and Mark Adler in 1992. It uses the DEFLATE compression algorithm, which combines LZ77 lossless data compression with Huffman coding. Gzip was created as a free replacement for the Unix compress program, which used an algorithm encumbered by patents. The .gz extension indicates a single file compressed with gzip; for directory archives, gzip is typically combined with tar to create .tar.gz or .tgz files.

Gzip is the standard compression tool on Linux and Unix systems and is built into virtually every Linux distribution. It is widely used for compressing log files, configuration files, and software packages. Web servers use gzip compression to reduce the size of HTML, CSS, JavaScript, and JSON responses before sending them to browsers, typically reducing text content by 60 to 80%. The gzip format includes a simple header with filename and modification time, followed by the compressed data stream.

How Gzip Compresses Data

Gzip's DEFLATE algorithm works in two stages: LZ77 replaces repeated byte sequences with back-references to earlier occurrences, and Huffman coding then assigns shorter codes to more frequent symbols.[1] A .gz file begins with a fixed header containing magic bytes, the compression method, flags, and an optional original filename and timestamp, and ends with a CRC-32 checksum and the original length for integrity verification.[1]

Single Files, Archives, and the Web

Gzip compresses only one data stream, so it does not bundle directories by itself; combining it with the tar archiver produces the familiar .tar.gz tarball.[3] The same DEFLATE method underlies HTTP content encoding, letting servers transmit text resources in compressed form to reduce transfer size.[2]

Origins and Successors

Gzip was written in the early 1990s as a patent-free replacement for the older Unix compress utility, whose LZW algorithm was encumbered by patents.[3] While newer compressors such as zstd and Brotli often achieve better ratios or speed, gzip's ubiquity and stable, openly documented format keep it a default across Unix tooling and the web.[2]

Technical Details

DevelopersJean-loup Gailly and Mark Adler[1]
File Extension.gz / .gzip[1]
MIME Typeapplication/gzip[1]
AlgorithmDEFLATE (LZ77 + Huffman coding)[1]
Single FileYes - compresses one file only (use tar for multiple)[1]
StreamingYes - supports on-the-fly streaming compression[1]
Toolsgzip command, zlib library, 7-Zip, WinRAR[1]

GZ vs Other Archive Formats

FeatureGZZIPBZ2XZ
Compression algorithmDEFLATE[1]DEFLATEBWTLZMA2
Multiple filesSingle stream[1]YesSingle streamSingle stream
Compression ratioModerateModerateHighVery high
SpeedFast[3]FastSlowerSlow
Best forSingle-file / streamsGeneral sharingBetter ratioMax ratio

GZ compresses one stream quickly, trading some ratio against the slower but tighter BZ2 and XZ.

Pros and Cons

Advantages

Standard Linux Compression

The universal compression standard on Unix and Linux - available on every system without installation.

Fast Compression Speed

DEFLATE compression is significantly faster than bzip2 or xz, making gzip suitable for frequent compression tasks.

Web Server Compression

Built-in web server feature for compressing HTTP responses, reducing page load times by 60 to 80% for text content.

Streaming Friendly

Supports single-pass streaming compression, making it ideal for compressing data in pipes and over networks.

Disadvantages

Single File Only

Gzip compresses only one file at a time. To compress a directory, you must first create a tar archive.

Weaker Compression than bzip2 or xz

DEFLATE provides good compression but bzip2 and xz consistently produce smaller files at the cost of slower processing.

No Multi-Volume Support

Does not support splitting compressed output across multiple files.

No Internal Directory Structure

Unlike ZIP or 7Z, a .gz file does not contain a directory listing - just compressed data for a single file.

When to Use GZ (Gzip)

Here are the most common situations where GZ (Gzip) is the right choice:

Linux Log Compression

Compress and archive log files on Linux servers using gzip to save disk space.

Software Distribution on Linux

Source code tarballs (.tar.gz) are the standard distribution format for open-source software.

Web Server Optimization

Configure Apache, Nginx, or other web servers to gzip HTML, CSS, and JavaScript responses automatically.

Data Pipeline Compression

Use gzip in shell pipelines to compress data streams between processes without writing temporary files.

Convert GZ (Gzip) Files

Need to convert your GZ files? Use our free online converter.

Try Archive Converter Free

Frequently Asked Questions about GZ (Gzip)

What is the difference between .gz and .tar.gz?

A .gz file is a single file compressed with gzip. A .tar.gz (or .tgz) file is a tar archive of multiple files and directories that has been compressed with gzip. Most Linux software is distributed as .tar.gz packages.

Is gzip the same as ZIP?

No. Gzip and ZIP both use the DEFLATE algorithm, but they are different formats. ZIP is a container that can hold multiple files with individual compression. Gzip compresses a single file; it is used with tar for multi-file archives.

How do I decompress a .gz file on Linux?

Use the command: gunzip filename.gz - or: gzip -d filename.gz - For .tar.gz files: tar -xzf filename.tar.gz

Can I open GZ files on Windows?

Yes. 7-Zip, WinRAR, and WinZip can extract .gz files on Windows. These applications handle both .gz and .tar.gz files.

What compression level should I use?

The default gzip compression level (6 of 9) provides a good balance of speed and size. Use -9 for maximum compression when size is critical and speed is not.

References

  1. GZIP File Format - RFC 1952 (IETF)
  2. GZIP - Library of Congress
  3. gzip - Wikipedia