{
  "slug": "lossless-compression",
  "term": "Lossless compression",
  "aliases": [
    "Lossless data compression"
  ],
  "definition": "Lossless compression encodes data so that decoding can reconstruct the original input exactly without discarding information.",
  "note": "Recovery: For byte-oriented formats such as DEFLATE and Zstandard, correct decoding reconstructs the input bytes. This guarantee applies to the encoder's input, not information discarded before encoding. Different valid encodings can recover the same input; recompression need not reproduce the same compressed bytes. [rfc8878] [rfc1951]\n\nSpace: No lossless compressor can make every possible input smaller. Framing and incompressible data can increase stored size; a codec label alone is not a capacity estimate. Filesystem allocation and metadata affect occupied storage, which is distinct from encoded-stream length. [rfc1951] [btrfs-compression]\n\nDependencies: A Zstandard frame may require an external dictionary even when its dictionary-ID field is absent. Retain the required dictionary and a compatible decoder alongside the compressed data. [rfc8878]\n\nCounting bound: With one fixed decoder and fixed external context, 65,536 possible two-octet inputs compete for only 257 shorter octet strings (the empty string and 256 one-octet strings). At most 257 inputs can shorten; this is a counting bound, not a measured compression ratio. Per-object side information that varies with the input must be counted too. Shannon's source-coding result concerns average rates for a specified source, not guaranteed savings on each file. [rfc1951] [shannon1948]",
  "status": "shipping",
  "advantages": [
    {
      "text": "Byte-exact reconstruction supports compressing arbitrary file payloads without accepting deliberate information loss.",
      "citationIds": [
        "rfc1951",
        "rfc8878"
      ]
    }
  ],
  "limitations": [
    {
      "text": "Reversibility does not prove that integrity checks were executed: Zstandard's content checksum is optional, and RFC 8878 permits decoders to ignore it.",
      "citationIds": [
        "rfc8878"
      ]
    },
    {
      "text": "Losslessness alone does not provide random access; DEFLATE and base Zstandard formats do not attempt to support it.",
      "citationIds": [
        "rfc1951",
        "rfc8878"
      ]
    }
  ],
  "related": [
    "gorilla-compression",
    "chimp-compression",
    "fpc",
    "fpzip",
    "zfp",
    "error-bounded-lossy-compression",
    "roaring-bitmap",
    "transparent-compression",
    "data-reduction-ratio",
    "compression-dictionary",
    "deflate",
    "zstandard",
    "asymmetric-numeral-systems",
    "compression-ratio",
    "elias-fano",
    "golomb-coding",
    "rice-coding",
    "run-length-encoding",
    "bit-packing",
    "huffman-coding",
    "delta-encoding",
    "delta-of-delta-encoding",
    "frame-of-reference",
    "patched-frame-of-reference",
    "fsst",
    "burrows-wheeler-transform",
    "front-coding",
    "grammar-compression",
    "prediction-by-partial-matching",
    "tunstall-coding",
    "byte-pair-encoding",
    "entropy-coding",
    "lz78",
    "lzw",
    "lz77",
    "rubikfs"
  ],
  "supersedes": [],
  "supersededBy": [],
  "firstSeen": null,
  "lastSeen": null,
  "citations": [
    {
      "id": "rfc1951",
      "title": "RFC 1951: DEFLATE, sections 1.1, 1.3-1.4 and 4",
      "url": "https://www.rfc-editor.org/rfc/rfc1951.html",
      "accessed": "2026-11-17"
    },
    {
      "id": "rfc8878",
      "title": "RFC 8878: Zstandard, sections 2, 3, 3.1.1 and 3.1.1.1.3",
      "url": "https://www.rfc-editor.org/rfc/rfc8878.html",
      "accessed": "2026-11-17"
    },
    {
      "id": "btrfs-compression",
      "title": "Btrfs-progs v6.16: Compression, extent granularity and incompressible data",
      "url": "https://raw.githubusercontent.com/kdave/btrfs-progs/v6.16/Documentation/ch-compression.rst",
      "accessed": "2026-11-17"
    },
    {
      "id": "shannon1948",
      "title": "Shannon (1948): A Mathematical Theory of Communication, sections 9-10; corrected reprint",
      "url": "https://web.mit.edu/6.441/spring05/reading/shannon1948.pdf",
      "accessed": "2026-11-17"
    }
  ],
  "updated": "2026-11-22",
  "provenance": [
    "Source synthesis of general byte-preserving compression and format-specific examples; no measured compression ratio, speed or corruption rate is claimed.",
    "RFC 8878 is used for frame semantics, not as a statement of HTTP content-coding limits."
  ]
}
