You've probably noticed some websites feel snappier than others, even on the same connection. A lot of that speed comes from a quiet hero: compression. Gzip, a format first released in 1992, still handles the bulk of web text compression today, and along with Google's Brotli, it accounts for nearly all HTTP content-encoding used across the web (HTTP Archive Web Almanac annual survey). This guide walks through what gzip is, how to use it, and when you might want to switch to a newer alternative.

First released: 1992 ·
Compression algorithm: Deflate (LZ77 + Huffman coding) ·
Typical file size reduction: 60–70% ·
Standardized: IETF RFC 1952 (1996) ·
Primary use: HTTP compression and file archiving

Quick snapshot

1Confirmed facts
2What's unclear
3Timeline signal
  • 1992: gzip released as a replacement for compress
  • 1996: IETF RFC 1952 standardises gzip format
  • 2015: Brotli (RFC 7932) introduced by Google
  • 2016: Zstandard released by Facebook
4What's next
  • Zstd HTTP content-encoding support reached about 71.65% browser share as of June 2025 (SpeedVitals)
  • CDNs increasingly offer Brotli precompression for static assets (WP Rocket)

These four cards frame the core tension: gzip's universal support versus the better ratios of its successors.

Core specs of gzip
Full name GNU zip (gzip)
Algorithm Deflate (RFC 1951)
File extension .gz
MIME type application/gzip
Decompression tool gunzip / gzip -d
Streaming support Yes (via zcat)

What is gzip used for?

Lossless file compression and decompression

HTTP content encoding for faster web delivery

  • When a server sends a response with the header Content-Encoding: gzip, browsers automatically decompress the data, reducing transfer size (HTTP Archive Web Almanac).
  • Gzip compresses textual HTTP responses (HTML, CSS, JavaScript, XML) by about 60–70% on average (DebugBear web performance monitoring).

Standard archiving combined with tar

  • The common .tar.gz format (also called tarball) bundles multiple files with tar and then compresses the archive with gzip.
  • It remains the standard distribution format for Linux source code and many open-source projects.

The implication: gzip's three roles — file compression, HTTP encoding, and archiving — make it a Swiss Army knife, but each role now faces a more specialized challenger.

Bottom line: Site operators should enable gzip for HTTP compression because every browser supports it, but plan to layer Brotli on top for cacheable static assets.

How can I gzip a file?

Using the gzip command on Linux/macOS

  • Basic command: gzip file.txt produces file.txt.gz and removes the original.
  • To keep the original, use gzip -k file.txt or gzip -c file.txt > file.txt.gz.
  • Decompress with gunzip file.txt.gz or gzip -d file.txt.gz.

Creating .gz files on Windows (7‑Zip, PowerShell)

  • 7‑Zip: right‑click the file, choose 7‑Zip → Add to archive, select gzip format.
  • PowerShell: Compress-Archive -Path file.txt -DestinationPath file.gz (note: creates .zip, not .gz; use .NET System.IO.Compression.GzipStream for true gzip).

Gzip compression in programming languages (Python, Node.js)

  • Python: use the built‑in gzip module — with gzip.open('file.txt.gz', 'wt') as f:.
  • Node.js: use the zlib module — zlib.gzip(input, callback) or pipe through zlib.createGzip().
  • All major languages ship with gzip support, making it trivial to compress data programmatically.

The pattern: the command-line basics cover 90% of use cases, and the universal library support means you never have to hunt for a third-party tool.

Bottom line: System administrators should learn the basic gzip and gunzip commands once; developers can rely on built-in libraries in every major language.

Is there a better compression than gzip?

Brotli: better compression ratio for web content

XZ/LZMA: higher ratio at slower speed

  • XZ uses the LZMA2 algorithm and achieves very strong compression ratios, but compression is much slower than gzip or Brotli (R-bloggers).
  • It is not supported as an HTTP content-encoding in browsers — its main use is offline distribution (Linux packages, software archives).

Zstandard (Zstd): fast compression with adjustable levels

  • Facebook introduced Zstd in August 2016, claiming both higher ratios and faster decompression than gzip (Meta Engineering).
  • Decompression speed often surpasses both gzip and Brotli, making it attractive for high‑traffic servers (DebugBear).
  • As of June 2025, Zstd HTTP content-encoding had about 71.65% browser support, with no Safari support (SpeedVitals).

Four algorithms, one pattern: each improvement in ratio trades off either compression speed or browser support.

Algorithm Typical ratio (vs gzip) Compression speed Browser support (mid‑2025)
gzip Baseline Fast ~100%
Brotli 15–30% smaller Moderate–slow (high levels) ~95.9%
XZ 10–40% smaller than gzip Very slow Not supported as HTTP encoding
Zstd Similar to Brotli Fast (decompression fastest) ~71.65%

The catch: no single algorithm wins on all three axes — the best choice depends on whether you prioritize ratio, speed, or compatibility.

The catch

Brotli's slower compression makes it suboptimal for on‑the‑fly compression of dynamic responses, so many CDNs precompress static assets with Brotli and serve gzip as a fallback to older clients.

When not to use gzip?

Already compressed formats (images, video, archives)

  • JPEG, PNG, MP4, and other media formats already use compression; gzip typically adds less than 2% savings (DebugBear).
  • Applying gzip to already compressed archives (e.g., .zip, .gz itself) wastes CPU with no benefit.

Very small files where overhead negates savings

  • For files under ~200 bytes, the gzip header and dictionary can increase total size.
  • Most web servers apply a minimum file‑size threshold (e.g., 1 KB) before compressing.

Environments where Brotli is already supported and preferred

  • If all target clients support Brotli (modern browsers), Brotli is recommended over gzip for static assets (CubePath CDN/infra docs).
  • Gzip still makes sense as a universal fallback for Brotli‑incompatible clients.

What this means: gzip's value today is as a baseline — it works everywhere, but applying it blindly to every resource wastes server cycles.

Bottom line: System administrators should skip gzip on media files and tiny payloads, and let Brotli handle static assets for modern browsers while keeping gzip as the fallback.

What is the difference between gunzip and zcat?

gunzip: decompresses to a file

  • gunzip file.gz decompresses file.gz to file and removes the .gz version by default.
  • It is functionally identical to gzip -d, and many systems symlink one to the other.

zcat: decompresses to standard output

  • zcat file.gz writes decompressed data to stdout, leaving the original .gz intact.
  • Equivalent to gunzip -c file.gz.

Equivalent utilities and usage examples

  • Pipe decompressed output directly: zcat file.gz | grep pattern or zcat file.gz | less.
  • Both commands come standard with gzip installations on Linux and macOS.

The pattern: gunzip writes a file, zcat writes to the pipe — choose based on whether you want a permanent file or a temporary inspection.

Bottom line: Developers should use gunzip when they need a decompressed file on disk and zcat when they want to pipe contents into a text processor without creating a file.

Upsides

  • Universally supported by every browser and server
  • Fast decompression, minimal CPU overhead on clients
  • Trivial to enable in Apache (mod_deflate) and Nginx (ngx_http_gzip_module)
  • Works with every programming language standard library

Downsides

  • Weakest compression ratio among modern alternatives
  • No advantages over Brotli for static web assets
  • Higher memory usage during decompression than Zstd
  • Not suitable for small payloads due to header overhead

Confirmed vs. unclear: the state of gzip

Confirmed facts

  • Gzip uses the Deflate algorithm (LZ77 + Huffman coding) (Google research).
  • Brotli achieves better compression ratios than gzip for typical web assets by 15–30% (R-bloggers).
  • Gzip is defined in IETF RFC 1952 (HTTP Archive).
  • The gunzip command decompresses .gz files and removes the compressed version by default.
  • On a sample HTML file, gzip reduced size by about 65% while Brotli reduced it by about 70% (DebugBear).

What's unclear

  • Exact compression ratio improvement of Brotli over gzip varies by content type and compression level (R-bloggers).
  • Whether XZ or Zstd will replace gzip as the default web compression has not been determined (SpeedVitals).
  • The long‑term impact of Zstd on CDN cost and energy consumption is not yet documented in public research.

"The file format is designed to be compatible with the widely used GZIP utility."

— IETF RFC 1952 (official spec)

"Gzip is a file format and a software application used for file compression and decompression."

Wikipedia community encyclopaedia

"Gzip is a file format designed to compress HTTP content before it is delivered to a client."

— Imperva (CDN security vendor)

Gzip earned its place as the baseline compression format because it works everywhere. But the web is shifting: Brotli is now the default for static assets on most CDNs, and Zstd is gaining ground for dynamic responses where decompression speed matters. For the average site operator, the choice is clear: enable Brotli precompression for cacheable content with gzip fallback, and keep gzip as the fast, safe option for dynamic pages where every millisecond of compression time hurts TTFB. The pattern is clear: gzip will not disappear, but its role is narrowing to universal fallback.

Related reading: **Optimization Tips** ? **Mpgh Ahrefs Semrush Moz Majestic**

Additional sources

psychz.net, giannirosato.com, oshyn.com

Frequently asked questions

What is the gzip file extension?

The standard extension for files compressed with gzip is .gz.

How to install gzip on Ubuntu?

Run sudo apt install gzip. Most Ubuntu installations include gzip by default.

Does gzip compress directories?

No – gzip compresses only single files. To compress a directory, first archive it with tar, then compress the archive: tar -czf archive.tar.gz directory/.

What is the difference between gzip and tar?

Gzip compresses data; tar bundles multiple files and directories. They are often combined as .tar.gz.

How to check the gzip compression level?

Run gzip -l file.gz to see the compression ratio and the uncompressed size.

Is gzip lossless?

Yes – gzip is a lossless compression format. Decompression reproduces the original data exactly.

Can gzip compress multiple files?

By itself, no. Use tar -czf archive.tar.gz file1 file2 to pack multiple files before gzipping.

How to decompress a gzip file without removing the .gz file?

Use zcat file.gz > newfile or gunzip -c file.gz > newfile. Both keep the original .gz intact.