{
  "schemaVersion": 1,
  "contentVersion": "ca42e61ede0a24f789d7287a0001244ad22f4abf",
  "id": "docs/codecs/data/gzip",
  "collection": "docs",
  "title": "gzip",
  "description": "gzip is the ubiquitous DEFLATE compressor: universally readable and fast, but with a weaker ratio than newer tools; pigz adds multithreading.",
  "canonicalUrl": "https://encode.wiki/codecs/data/gzip/",
  "apiUrl": "https://encode.wiki/api/v1/documents/docs/codecs/data/gzip.json",
  "markdownUrl": "https://encode.wiki/api/v1/markdown/docs/codecs/data/gzip.md",
  "status": "current",
  "tags": [
    "migrated"
  ],
  "license": "CC BY-SA 4.0",
  "dates": {
    "lastVerified": "2026-10-08T00:00:00.000Z"
  },
  "authors": [],
  "sources": [
    {
      "title": "GNU gzip manual",
      "url": "https://www.gnu.org/software/gzip/manual/gzip.html",
      "accessedAt": "2026-10-08T00:00:00.000Z"
    },
    {
      "title": "RFC 1952 — GZIP file format specification",
      "url": "https://www.rfc-editor.org/rfc/rfc1952",
      "accessedAt": "2026-10-08T00:00:00.000Z"
    },
    {
      "title": "pigz",
      "url": "https://zlib.net/pigz/",
      "accessedAt": "2026-10-08T00:00:00.000Z"
    }
  ],
  "provenance": {
    "originUrl": "https://github.com/av1-community-contributors/codec-wiki/blob/37c3317fd058b23c71a87679bed5619a98f77752/docs/data/gzip.mdx",
    "originCommit": "37c3317fd058b23c71a87679bed5619a98f77752",
    "migratedAt": "2026-08-21T00:00:00.000Z",
    "modified": true,
    "originPath": "docs/data/gzip.mdx"
  },
  "headings": [
    {
      "depth": 2,
      "text": "Common commands",
      "anchor": "common-commands"
    },
    {
      "depth": 2,
      "text": "pigz: parallel gzip",
      "anchor": "pigz-parallel-gzip"
    },
    {
      "depth": 2,
      "text": "Directories",
      "anchor": "directories"
    },
    {
      "depth": 2,
      "text": "HTTP and web delivery",
      "anchor": "http-and-web-delivery"
    },
    {
      "depth": 2,
      "text": "Pitfalls",
      "anchor": "pitfalls"
    }
  ],
  "sections": [
    {
      "id": "_preamble",
      "title": "Page introduction",
      "depth": 0,
      "canonicalUrl": "https://encode.wiki/codecs/data/gzip/",
      "apiUrl": "https://encode.wiki/api/v1/sections/docs/codecs/data/gzip/_preamble.json",
      "markdownUrl": "https://encode.wiki/api/v1/sections/docs/codecs/data/gzip/_preamble.md",
      "checksum": "804ffb57b2b888e5e279c1fa1a9105dfedadb1cdeec1cb369dc5352f8a30cf40",
      "bytes": 423
    },
    {
      "id": "common-commands",
      "title": "Common commands",
      "depth": 2,
      "anchor": "common-commands",
      "canonicalUrl": "https://encode.wiki/codecs/data/gzip/#common-commands",
      "apiUrl": "https://encode.wiki/api/v1/sections/docs/codecs/data/gzip/common-commands.json",
      "markdownUrl": "https://encode.wiki/api/v1/sections/docs/codecs/data/gzip/common-commands.md",
      "checksum": "a458193493ade47d0b3bc6fca4f205dee2b02ac58758b3106ff0685910d634d2",
      "bytes": 835
    },
    {
      "id": "pigz-parallel-gzip",
      "title": "pigz: parallel gzip",
      "depth": 2,
      "anchor": "pigz-parallel-gzip",
      "canonicalUrl": "https://encode.wiki/codecs/data/gzip/#pigz-parallel-gzip",
      "apiUrl": "https://encode.wiki/api/v1/sections/docs/codecs/data/gzip/pigz-parallel-gzip.json",
      "markdownUrl": "https://encode.wiki/api/v1/sections/docs/codecs/data/gzip/pigz-parallel-gzip.md",
      "checksum": "3ad4294da2e6f49354c1b4b63722e3690e793aec7e794c70a23870b9a2c43b60",
      "bytes": 360
    },
    {
      "id": "directories",
      "title": "Directories",
      "depth": 2,
      "anchor": "directories",
      "canonicalUrl": "https://encode.wiki/codecs/data/gzip/#directories",
      "apiUrl": "https://encode.wiki/api/v1/sections/docs/codecs/data/gzip/directories.json",
      "markdownUrl": "https://encode.wiki/api/v1/sections/docs/codecs/data/gzip/directories.md",
      "checksum": "84b35400c0848331bb6f8166d61cf499be389f4243be8516bfbf41b8ad7b36f8",
      "bytes": 304
    },
    {
      "id": "http-and-web-delivery",
      "title": "HTTP and web delivery",
      "depth": 2,
      "anchor": "http-and-web-delivery",
      "canonicalUrl": "https://encode.wiki/codecs/data/gzip/#http-and-web-delivery",
      "apiUrl": "https://encode.wiki/api/v1/sections/docs/codecs/data/gzip/http-and-web-delivery.json",
      "markdownUrl": "https://encode.wiki/api/v1/sections/docs/codecs/data/gzip/http-and-web-delivery.md",
      "checksum": "34dd1969e0b8940a49283347d9d047c6b9b1b48b837b7a2c48172918ade071dd",
      "bytes": 383
    },
    {
      "id": "pitfalls",
      "title": "Pitfalls",
      "depth": 2,
      "anchor": "pitfalls",
      "canonicalUrl": "https://encode.wiki/codecs/data/gzip/#pitfalls",
      "apiUrl": "https://encode.wiki/api/v1/sections/docs/codecs/data/gzip/pitfalls.json",
      "markdownUrl": "https://encode.wiki/api/v1/sections/docs/codecs/data/gzip/pitfalls.md",
      "checksum": "b83ee760580e7f213509b0cf9ba0069abbae1b1a3f0b7e3152735fb643c58a9b",
      "bytes": 376
    }
  ],
  "outboundReferences": [
    "/codecs/data/brotli/",
    "/codecs/data/tar/",
    "/codecs/data/zip/",
    "/codecs/data/zstd/"
  ],
  "checksum": "a8fc53196c7251ca17fc1599e513a6a5f99e8a71c05de8bbf5ca95f2fdbced64",
  "contentFormat": "markdown",
  "markdown": "gzip is the oldest and most universally readable general-purpose compressor. It uses DEFLATE (32 KiB window), the same algorithm inside ZIP and PNG, and every Unix system, browser, programming language and CDN reads it. Its ratio is the weakest of the common tools, but it is fast, needs almost no memory, and works everywhere. Use it when compatibility matters more than size; otherwise prefer [zstd](/codecs/data/zstd/).\n\n## Common commands\n\n```sh\ngzip -k file               # file.gz, level 6, keep the original\ngzip -9 -k file            # best ratio; slower, usually a few % smaller\ngzip -d file.gz            # decompress (or gunzip)\nzcat file.gz | less        # to stdout (gzip -dc)\ngzip -t file.gz            # test integrity\ngzip -l file.gz            # sizes and ratio\n```\n\nLike xz, gzip **replaces** the input file unless you pass `-k`. Levels run 1–9, default 6; `-9` buys little over 6, and zopfli-style optimisers (`pigz -11`) can squeeze a few percent more for files that are compressed once and served often.\n\nFor reproducible output, add `-n`, which stops gzip storing the original file name and timestamp in the header: the same input then gives the same bytes. `--rsyncable` makes the stream friendlier to rsync, at a small cost in size.\n\n## pigz: parallel gzip\n\npigz is a drop-in multithreaded gzip that writes standard `.gz` files:\n\n```sh\npigz -p 8 -9 -k file\npigz -dc file.gz | tar -x\ntar -I pigz -cf backup.tar.gz dir/\n```\n\nCompression scales with cores; decompression of a normal `.gz` is mostly single-threaded, since DEFLATE blocks depend on each other. It is not part of most base installs.\n\n## Directories\n\ngzip compresses one stream. For a tree use [tar](/codecs/data/tar/):\n\n```sh\ntar -czf backup.tar.gz dir/\ntar -xzf backup.tar.gz\n```\n\nConcatenating `.gz` files produces a valid multi-member `.gz` that decompresses to the concatenated data, which is useful for appending to compressed logs.\n\n## HTTP and web delivery\n\n`gzip` is the fallback content coding supported by every client. Servers compress responses on the fly at a low-to-medium level; for static assets, precompress once at `-9` (or with `pigz -11`) and serve it with `Content-Encoding: gzip`. [Brotli](/codecs/data/brotli/) compresses text assets noticeably smaller, but gzip remains the compatibility baseline.\n\n## Pitfalls\n\n- **Already-compressed data** (JPEG, MP4, ZIP, video) does not shrink; gzip may make it slightly larger.\n- **`.gz` is not `.zip`.** gzip stores one file stream with no directory structure; ZIP stores many entries. See [ZIP](/codecs/data/zip/).\n- **Corruption:** the CRC detects damage but gzip has no recovery; a damaged stream is lost from the bad point onward.\n"
}
