Skip to content

This file type cannot be converted in the browser.

┌─ FILE ANALYSIS ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
DEVELOPER : Jean-loup Gailly & Mark Adler
CATEGORY : Archive
MIME TYPE : application/gzip
MAGIC BYTES : 1F8B
────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────

What is a GZ file?

GZ (GNU Zip) is a file compression format based on the DEFLATE algorithm, created by Jean-loup Gailly and Mark Adler in 1992 as a free replacement for the proprietary compress format on Unix systems. Unlike ZIP, GZ compresses a single file or data stream without bundling multiple files — for multi-file archives, GZ is combined with TAR, producing the ubiquitous .tar.gz (also written .tgz) format.

GZ is deeply embedded in Unix/Linux infrastructure: log rotation, web server content encoding, software distribution, and database backups all rely on it. The format is lossless and patent-free, making it universally available.

How to open GZ files

  • gunzip / gzip -d (macOS, Linux) — Built-in CLI: gunzip file.gz
  • tar (macOS, Linux) — Extract .tar.gz in one step: tar -xzf archive.tar.gz
  • 7-Zip (Windows) — Free, open-source
  • WinRAR (Windows) — Built-in GZ support
  • The Unarchiver (macOS) — Free, handles .gz and .tar.gz
  • PeaZip (Windows, Linux) — Free alternative

Technical specifications

PropertyValue
AlgorithmDEFLATE (LZ77 + Huffman coding)
Single-fileCompresses one file or stream
ChecksumCRC-32 for integrity verification
ConcatenationMultiple GZ streams can be concatenated
Common pairs.tar.gz / .tgz, .sql.gz, .log.gz
Magic bytes1F 8B
MIME typeapplication/gzip

Common use cases

  • Web compression: HTTP Content-Encoding: gzip header compresses text responses (HTML, CSS, JS, JSON) for faster transfer — typically 60-80% smaller
  • Log file rotation: logrotate on Linux compresses old log files with gzip to save disk space
  • Source code distribution: .tar.gz tarballs are the standard format for open-source software releases
  • Database backups: mysqldump | gzip > backup.sql.gz creates compressed SQL dumps
  • Pipeline compression: GZ can compress data streams in real-time (piped between processes)

GZ vs other compression formats

FormatAlgorithmRatioSpeedSingle-file
GZDEFLATEGoodFast
BZ2BWT + HuffmanBetterSlower
XZLZMA2BestSlowest
ZIPDEFLATEGoodFast❌ (multi-file)
ZstandardzstdVery goodVery fast

For most use cases, GZ offers the best balance of speed and compression. XZ is preferred when maximum compression matters more than time. Zstandard (.zst) is increasingly replacing GZ in high-performance scenarios.

Working with GZ on the command line

# Compress a file (replaces original with .gz)
gzip file.sql

# Compress while keeping the original
gzip -k file.sql

# Decompress
gunzip file.sql.gz
# or
gzip -d file.sql.gz

# Create .tar.gz archive
tar -czf archive.tar.gz /path/to/folder/

# Extract .tar.gz archive
tar -xzf archive.tar.gz

# View compressed file without extracting
zcat file.txt.gz | head -20

HTTP gzip compression

Web servers enable gzip compression for text-based responses to reduce bandwidth and improve load times. In Nginx: gzip on; gzip_types text/html text/css application/javascript;. In Apache: enable mod_deflate. Browsers advertise support via the Accept-Encoding: gzip, deflate, br request header, and servers respond with Content-Encoding: gzip when they compress the body. This is transparent to the end user but significantly reduces page load times on slow connections.

Integrity verification

GZ files include a CRC-32 checksum and the uncompressed file size. If a GZ file is truncated or corrupted during transfer, gunzip will report an error. Verify integrity with gzip -t file.gz (test mode) before depending on the contents.