An .lzma file is a 13-byte header followed by one LZMA stream. This page
follows
lzma-specification.txt
from Igor Pavlov’s LZMA SDK (a draft, read 2026-11-12 from a mirror of the SDK’s
DOC folder). Numbers are
little-endian. The compressed data is described on
LZMA coding.
Fields
| Offset | Size | Name | Description |
|---|---|---|---|
0 | 1 | Properties | (pb × 5 + lp) × 9 + lc; must be less than 225. See properties. |
1 | 4 | Dictionary size | In bytes. A decoder uses at least 4,096 (212) even if a smaller value is written. |
5 | 8 | Uncompressed size | Size of the decompressed data, or FF FF FF FF FF FF FF FF when unknown. |
13 | … | LZMA data | The range-coded stream. |
Properties
To unpack the byte d: lc = d % 9, d = d / 9,
lp = d % 5, pb = d / 5.
| Name | Range | Meaning |
|---|---|---|
lc | 0 to 8 | Literal context bits: how many high bits of the previous byte choose the model for the next literal. |
lp | 0 to 4 | Literal position bits: how many low bits of the position choose it too. |
pb | 0 to 4 | Position bits: how many low bits of the position choose the models for match and repeat decisions. |
The byte must be below 225 (9 × 5 × 5); a decoder rejects anything else. lc 3,
lp 0, pb 2 give 5D; the specification calls lc 3 and lp 0 the default
parameters. The format has no signature.
Where the data ends
- With a known size, the decoder stops after that many bytes. The stream may still end with an end marker, which is then optional.
- With an unknown size, the stream must end with the end marker: a match whose
distance decodes to
FFFFFFFF. - After the last bit the range decoder’s
Codemust be 0; the specification calls this check a very good way to detect corruption.
The format has no checksum, so damage may go unnoticed. The same five property bytes (properties and dictionary size) are used in 7z for the LZMA coder, without the size.
Example
5D properties: lc 3, lp 0, pb 2
00 00 80 00 dictionary 8 MiB (0x00800000)
FF FF FF FF FF FF FF FF uncompressed size unknown: an end marker follows the data
00 … LZMA data; the first byte of the range coder is always 00