{
  "slug": "lzw",
  "term": "LZW",
  "aliases": [
    "Lempel-Ziv-Welch"
  ],
  "definition": "LZW is a lossless dictionary-coding method that replaces input strings with codes while the encoder and decoder reconstruct matching dictionaries.",
  "note": "The initial dictionary contains single-symbol strings. Encoding emits a code for the longest recognized string and adds that string extended by the next symbol; the extension symbol also starts the next parsing step. [welch-original] [tiff6-lzw]\n\nA decoder derives new entries from prior output rather than receiving a complete learned dictionary separately. It must still follow the format's initialization, code-width, reset and packing rules. [welch-original] [gif89a-lzw] [tiff6-lzw]\n\nGIF packs codes least-significant-bit first. At a full table, clearing can be deferred: the decoder keeps the table unchanged until a Clear code arrives. Its End of Information code and data-sub-block terminator serve different layers. [gif89a-lzw]\n\nTIFF 6.0 packs LZW codes high-to-low regardless of TIFF byte order, restarts each strip and changes code width earlier than GIF. A GIF decoder is not a TIFF decoder merely by reversing bit order; the optional differencing predictor is a separate transform. [tiff6-lzw] [gif89a-lzw]",
  "related": [
    "lz78",
    "lossless-compression",
    "compression-dictionary"
  ],
  "citations": [
    {
      "id": "welch-original",
      "title": "Welch (1984): A Technique for High-Performance Data Compression, pp. 8-19",
      "url": "https://courses.cs.duke.edu/spring03/cps296.5/papers/welch_1984_technique_for.pdf",
      "accessed": "2026-11-19"
    },
    {
      "id": "gif89a-lzw",
      "title": "CompuServe GIF89a: Appendix F and deferred-clear clarification",
      "url": "https://www.w3.org/Graphics/GIF/spec-gif89a.txt",
      "accessed": "2026-11-19"
    },
    {
      "id": "tiff6-lzw",
      "title": "Aldus TIFF Revision 6.0 (1992): sections 13-14, LZW compression and differencing predictor",
      "url": "https://image-js.github.io/tiff/media/TIFF6.pdf",
      "accessed": "2026-11-19"
    },
    {
      "id": "hesela-lzw-formats",
      "title": "Hesela: Recover the dictionary and the format conventions",
      "url": "https://hesela.com/analyses/compressed-archives-dictionary-dependencies/#lz-dictionary-formats",
      "accessed": "2026-11-19"
    }
  ],
  "status": "shipping",
  "advantages": [],
  "limitations": [],
  "supersedes": [],
  "supersededBy": [],
  "firstSeen": null,
  "lastSeen": null,
  "updated": "2026-11-19",
  "provenance": [
    "Algorithm and format synthesis, not a decoder conformance test. Welch's paper is DOI 10.1109/MC.1984.1659158; GIF89a and TIFF 6.0 are separate contracts."
  ]
}
