An .lz4 file is one or more frames. This page follows the LZ4 Frame Format
Description, version 1.6.5, in the lz4 repository. Numbers are little-endian. The
compressed data inside each block is described on block
format.
Frame layout
| Field | Size | Description |
|---|---|---|
| Magic number | 4 | 184D2204, stored 04 22 4D 18. |
| FLG | 1 | See FLG. |
| BD | 1 | See BD. |
| Content size | 0 or 8 | With the content size flag: the size of the original data. Informational. |
| Dictionary ID | 0 or 4 | With the dictionary ID flag: which dictionary the compressor used. |
| Header checksum | 1 | (xxh32(descriptor, 0) >> 8) & FF: the second byte of the xxHash-32, seed 0, of the descriptor from FLG to the last optional field. |
| Data blocks | … | See data blocks. |
| End mark | 4 | 00000000. |
| Content checksum | 0 or 4 | With the content checksum flag: xxHash-32, seed 0, of all the original data. |
FLG byte
| Bits | Name | Meaning |
|---|---|---|
| 7 and 6 | Version | Must be 01. |
| 5 | B.Indep | 1: blocks are independent. 0: each block may refer to up to 64 KB of the blocks before it. |
| 4 | B.Checksum | Each block is followed by a checksum. |
| 3 | C.Size | The content size field is present. |
| 2 | C.Checksum | The content checksum is present. |
| 1 | Reserved | Must be 0. |
| 0 | DictID | The dictionary ID field is present. |
BD byte
| Bits | Meaning |
|---|---|
| 7 | Reserved, 0. |
| 6 to 4 | Block maximum size: 4 64 KB, 5 256 KB, 6 1 MB, 7 4 MB. 0 to 3 are not used. |
| 3 to 0 | Reserved, 0. |
The lz4 command-line tool’s defaults, in its lz4io.c
(read 2026-11-12), are block size ID 7 (4 MB), independent blocks and a content
checksum, which make FLG 64 and BD 70.
Data blocks
| Field | Size | Description |
|---|---|---|
| Block size | 4 | Bit 31 set: the data is stored uncompressed. Bits 0 to 30: the size of the data, not counting a checksum. At most the block maximum size. |
| Data | … | LZ4 block format, or the bytes as they are. |
| Block checksum | 0 or 4 | With B.Checksum: xxHash-32, seed 0, of the stored data (before decoding). Present even for empty blocks. |
00000000 is the end mark, not a block; 80000000 is a valid
empty stored block. Data that does not compress must be stored.
Skippable frames
| Field | Size | Description |
|---|---|---|
| Magic number | 4 | Any of 184D2A50 to 184D2A5F. |
| Frame size | 4 | Size of the user data that follows. |
| User data | … | Ignored by decoders. |
A stream that must start with user data starts with an empty LZ4 frame, then the skippable frame. The same magic range is used by Zstandard.
Legacy frame
Written by early versions of the lz4 tool and still used by the Linux
kernel’s compressed images.
- Magic
184C2102, stored02 21 4C 18. - Then blocks, each a 4-byte compressed size and the compressed data. Every block is compressed, even when that makes it bigger, and every block but the last holds 8 MB of original data.
- No checksums. The frame ends at the end of the file or where another frame’s magic
number starts. The Linux kernel also accepts a zero size as an end mark, and so does
lz4since 1.11.0, but encoders should not write one.
Several frames
Frames are independent and each has its own settings. The specification does not
cover decoding several frames, but the lz4 tool decodes them all in
order, as one output.