{
  "schemaVersion": 1,
  "contentVersion": "ca42e61ede0a24f789d7287a0001244ad22f4abf",
  "id": "docs/codecs/data/zstd",
  "collection": "docs",
  "title": "zstd",
  "description": "Zstandard (zstd) is a fast general-purpose compressor with gzip-like speed at xz-like ratios; this page covers levels, threads, long-distance mode and HTTP use.",
  "canonicalUrl": "https://encode.wiki/codecs/data/zstd/",
  "apiUrl": "https://encode.wiki/api/v1/documents/docs/codecs/data/zstd.json",
  "markdownUrl": "https://encode.wiki/api/v1/markdown/docs/codecs/data/zstd.md",
  "status": "current",
  "tags": [
    "migrated"
  ],
  "license": "CC BY-SA 4.0",
  "dates": {
    "lastVerified": "2026-10-08T00:00:00.000Z"
  },
  "authors": [],
  "sources": [
    {
      "title": "zstd command-line manual (v1.5.7)",
      "url": "https://github.com/facebook/zstd/blob/v1.5.7/programs/zstd.1.md",
      "accessedAt": "2026-10-08T00:00:00.000Z"
    },
    {
      "title": "RFC 8878 — Zstandard Compression and the application/zstd Media Type",
      "url": "https://www.rfc-editor.org/rfc/rfc8878",
      "accessedAt": "2026-10-08T00:00:00.000Z"
    },
    {
      "title": "RFC 9659 — Window Sizing for Zstandard Content Encoding",
      "url": "https://www.rfc-editor.org/rfc/rfc9659",
      "accessedAt": "2026-10-08T00:00:00.000Z"
    },
    {
      "title": "7-Zip history",
      "url": "https://7-zip.org/history.txt",
      "accessedAt": "2026-10-08T00:00:00.000Z"
    },
    {
      "title": "Can I use — zstd content-encoding",
      "url": "https://caniuse.com/zstd",
      "accessedAt": "2026-10-08T00:00:00.000Z"
    }
  ],
  "provenance": {
    "originUrl": "https://github.com/av1-community-contributors/codec-wiki/blob/37c3317fd058b23c71a87679bed5619a98f77752/docs/data/zstd.mdx",
    "originCommit": "37c3317fd058b23c71a87679bed5619a98f77752",
    "migratedAt": "2026-08-21T00:00:00.000Z",
    "modified": true,
    "originPath": "docs/data/zstd.mdx"
  },
  "headings": [
    {
      "depth": 2,
      "text": "Common commands",
      "anchor": "common-commands"
    },
    {
      "depth": 3,
      "text": "Larger windows need matching decompression settings",
      "anchor": "larger-windows-need-matching-decompression-settings"
    },
    {
      "depth": 2,
      "text": "Archives and other formats",
      "anchor": "archives-and-other-formats"
    },
    {
      "depth": 2,
      "text": "HTTP",
      "anchor": "http"
    },
    {
      "depth": 2,
      "text": "Compared with others",
      "anchor": "compared-with-others"
    }
  ],
  "sections": [
    {
      "id": "_preamble",
      "title": "Page introduction",
      "depth": 0,
      "canonicalUrl": "https://encode.wiki/codecs/data/zstd/",
      "apiUrl": "https://encode.wiki/api/v1/sections/docs/codecs/data/zstd/_preamble.json",
      "markdownUrl": "https://encode.wiki/api/v1/sections/docs/codecs/data/zstd/_preamble.md",
      "checksum": "4a079cdc3b259c2b1527ece70a599b56645ecbcc4bdfc738c091f7f644176f3c",
      "bytes": 509
    },
    {
      "id": "common-commands",
      "title": "Common commands",
      "depth": 2,
      "anchor": "common-commands",
      "canonicalUrl": "https://encode.wiki/codecs/data/zstd/#common-commands",
      "apiUrl": "https://encode.wiki/api/v1/sections/docs/codecs/data/zstd/common-commands.json",
      "markdownUrl": "https://encode.wiki/api/v1/sections/docs/codecs/data/zstd/common-commands.md",
      "checksum": "36462155e182dfef311b9e71ce4e689a5b3da205ab7049daeebc2a37801fe72d",
      "bytes": 2248
    },
    {
      "id": "larger-windows-need-matching-decompression-settings",
      "title": "Larger windows need matching decompression settings",
      "depth": 3,
      "anchor": "larger-windows-need-matching-decompression-settings",
      "canonicalUrl": "https://encode.wiki/codecs/data/zstd/#larger-windows-need-matching-decompression-settings",
      "apiUrl": "https://encode.wiki/api/v1/sections/docs/codecs/data/zstd/larger-windows-need-matching-decompression-settings.json",
      "markdownUrl": "https://encode.wiki/api/v1/sections/docs/codecs/data/zstd/larger-windows-need-matching-decompression-settings.md",
      "checksum": "5fc5053ff0030086b9ede98cfaf5b74a4b3d390e0c9d2ce730933000e1419827",
      "bytes": 286
    },
    {
      "id": "archives-and-other-formats",
      "title": "Archives and other formats",
      "depth": 2,
      "anchor": "archives-and-other-formats",
      "canonicalUrl": "https://encode.wiki/codecs/data/zstd/#archives-and-other-formats",
      "apiUrl": "https://encode.wiki/api/v1/sections/docs/codecs/data/zstd/archives-and-other-formats.json",
      "markdownUrl": "https://encode.wiki/api/v1/sections/docs/codecs/data/zstd/archives-and-other-formats.md",
      "checksum": "7767782e4b797d5d702de26b60efb226e556854baf7ee83312139decabe5f2a3",
      "bytes": 412
    },
    {
      "id": "http",
      "title": "HTTP",
      "depth": 2,
      "anchor": "http",
      "canonicalUrl": "https://encode.wiki/codecs/data/zstd/#http",
      "apiUrl": "https://encode.wiki/api/v1/sections/docs/codecs/data/zstd/http.json",
      "markdownUrl": "https://encode.wiki/api/v1/sections/docs/codecs/data/zstd/http.md",
      "checksum": "922417c2ea1a8de323ff1b37e40f0ad11a817a8ab4a53f76e79e84a87e5be80b",
      "bytes": 574
    },
    {
      "id": "compared-with-others",
      "title": "Compared with others",
      "depth": 2,
      "anchor": "compared-with-others",
      "canonicalUrl": "https://encode.wiki/codecs/data/zstd/#compared-with-others",
      "apiUrl": "https://encode.wiki/api/v1/sections/docs/codecs/data/zstd/compared-with-others.json",
      "markdownUrl": "https://encode.wiki/api/v1/sections/docs/codecs/data/zstd/compared-with-others.md",
      "checksum": "fcce334a5033e64f735914292be19fa3ac7cbef266ad87bb5235a580f7c7a194",
      "bytes": 600
    }
  ],
  "outboundReferences": [
    "/codecs/data/7z/",
    "/codecs/data/brotli/",
    "/codecs/data/gzip/",
    "/codecs/data/tar/",
    "/codecs/data/xz/",
    "https://caniuse.com/zstd",
    "https://www.rfc-editor.org/rfc/rfc8878",
    "https://www.rfc-editor.org/rfc/rfc9659"
  ],
  "checksum": "7784754cbce9e3f7a91a4246d719229609c5d23a7b3d6edd5aed5415dec61eef",
  "contentFormat": "markdown",
  "markdown": "Zstandard (zstd) is Yann Collet's compressor, developed at Facebook (now Meta) and specified in [RFC 8878](https://www.rfc-editor.org/rfc/rfc8878). It compresses and decompresses faster than gzip at a better ratio, its high levels approach xz, and decompression speed barely depends on the level. That makes it the sensible default for archives, backups, logs, container images and intermediate files. Arch Linux packages are zstd-compressed, and the Linux kernel, btrfs, SquashFS and OpenZFS all support it.\n\n## Common commands\n\n```sh\nzstd file                      # file.zst, level 3, source kept\nzstd -19 -T0 file              # slower, much smaller, all cores\nzstd --ultra -22 -T0 file      # maximum; needs lots of memory\nzstd -d file.zst               # decompress\nzstd -dc file.zst | less       # to stdout\nzstd -t file.zst               # test integrity\n```\n\nUnlike gzip and xz, zstd **keeps** the input file by default (`--rm` deletes it). Output has a `.zst` extension.\n\n| Option            | Effect                                                                                                                       |\n| ----------------- | ---------------------------------------------------------------------------------------------------------------------------- |\n| `-1` … `-19`      | Compression level; default 3. `-19` is about the useful limit                                                                |\n| `--ultra -20…-22` | Even slower and memory-hungry, with small gains; the decoder also needs more memory                                          |\n| `--fast=N`        | Negative levels, faster than `-1` with worse ratios                                                                          |\n| `-T0`             | Use all cores (default is 1); also speeds up higher levels a lot                                                             |\n| `--long[=27]`     | Long-distance matching with a 128 MiB window; helps on big files with distant repeats (VM images, tarballs of similar trees) |\n| `--adapt`         | Change the level on the fly to match how fast the output is being consumed (good for piping over a network)                  |\n| `-D dict`         | Use a trained dictionary; `zstd --train files…` builds one. Big wins on many small similar files                             |\n\nLevels 3–9 are the sweet spot for logs, backups and anything compressed repeatedly. Use 19 for things compressed once and read many times.\n\n### Larger windows need matching decompression settings\n\nWith `--long=N` for N above 27, the decompressor must be given `--long=N` too (or `--memory=…`), otherwise it refuses the file to protect itself from huge allocations. Archives made with the default window decompress anywhere.\n\n## Archives and other formats\n\nzstd compresses one stream, not a directory, so combine it with [tar](/codecs/data/tar/):\n\n```sh\ntar --zstd -cf backup.tar.zst dir/\ntar -I 'zstd -19 -T0' -cf backup.tar.zst dir/\ntar -xf backup.tar.zst\n```\n\nThe `zstd` binary can also read and write gzip, xz and lzma streams (`--format=gzip`). [7-Zip](/codecs/data/7z/) can unpack `.zst` files since 24.01 but does not create them.\n\n## HTTP\n\n`zstd` is a registered HTTP content coding. Chrome and Edge 123, Firefox 126 and Safari 26.3 (iOS, or macOS 26.3 and later) advertise it in `Accept-Encoding`; see [Can I use](https://caniuse.com/zstd). HTTP zstd limits the window to 8 MiB ([RFC 9659](https://www.rfc-editor.org/rfc/rfc9659)), so do not serve files compressed with `--long` or `--ultra` levels (20–22) as `Content-Encoding: zstd`. Level 19 and below stay within the limit. Brotli ([brotli](/codecs/data/brotli/)) is the established alternative for static web assets and has wider browser support.\n\n## Compared with others\n\n| vs.                            | zstd                                                                          |\n| ------------------------------ | ----------------------------------------------------------------------------- |\n| [gzip](/codecs/data/gzip/)     | Faster at a similar or better ratio, and multithreaded                        |\n| [xz](/codecs/data/xz/)         | Slightly worse ratio at max, but decompresses several times faster            |\n| [brotli](/codecs/data/brotli/) | Faster; brotli wins on small text/web files thanks to its built-in dictionary |\n"
}
