LZ4 Block Format Inspector
100% client-side · specification
Inspect how an LZ4 block encodes input into sequences of [token, literal-length ext, literals, offset (LE16), match-length ext].
Hover or click any sequence or byte below to highlight its literals, match output, and back-reference source.
TT token (high: lit, low: match−4)
FF length ext
LL literals
OO OO offset (LE16)
source matched history
match copied output
Uncompressed bytes
Compressed LZ4 block (hex)
Sequences (click a row to pin highlight)
| # | Token | Literals | Offset | Match | Wire | Preview |
|---|
Anatomy of an LZ4 sequence
An LZ4 block is a flat series of sequences. Every sequence copies a run of uncompressed literals, then repeats an earlier slice of already-decoded output (a match):
[ Token (1 B) ] [ lit_len ext (0..N B) ] [ Literals (lit_len B) ] [ Offset (2 B, LE) ] [ match_len ext (0..N B) ] hi 4b | lo 4b if hi == 15 copied verbatim 1..65535 back if lo == 15
- Token byte
- Split into two 4-bit fields: the high nibble gives the literal length (
0..15), and the low nibble encodesmatch_length − 4(0..15), because the minimum match length is 4 bytes (MINMATCH = 4). - Extended lengths
- When either nibble equals
15, additional bytes are added until a byte strictly smaller than255is read. For example,15 + 255 + 12 = 282. - Back-reference & RLE
- The 16-bit little-endian
offsetpoints backward into already-decoded bytes (1..65535;0is invalid). Whenoffset < match_length, copying proceeds byte by byte as newly written bytes become part of the source — giving run-length encoding for free (try the Overlap / RLE preset above). - End of block
- The final sequence contains only literals (no offset or match), and the last 5 bytes of a conformant block are always literals. See
lz4_Block_format.mdfor the complete specification. - Block vs Frame
- This inspector displays a raw LZ4 block (no header, no stored uncompressed size). Interoperable
.lz4files and CLI streams wrap blocks inside an LZ4 Frame starting with the 4-byte magic number04 22 4D 18.