7-Zip file format
A 7-Zip archive, usually with a high compression ratio via LZMA/LZMA2.
- MIME type
- application/x-7z-compressed
- Extensions
- .7z
- Category
- Archives & compression
Magic-number signature
| 0x00000000 | 377ABCAF271C | 7z··'· | 7z magic |
About the 7-Zip format
7z is the native format of 7-Zip, supporting strong LZMA2 compression, solid archives and AES-256 encryption. The signature is 37 7A BC AF 27 1C. The first thirty-two bytes are the whole of the fixed layout: a signature, a format version, and a pointer to where the real header lives. Everything else — file names, sizes, timestamps, checksums, and the description of how the data was coded — sits in that header at the far end of the file, usually compressed itself. There are no per-file headers in between, which is what makes .7z compact and what makes a damaged one so much harder to salvage than a ZIP.
Header layout, byte by byte
| Offset | Length | Field | Meaning |
|---|---|---|---|
| 0 | 6 | Signature | 37 7A BC AF 27 1C. The first two bytes are the ASCII letters '7z', which is why they show up as readable text; the remaining four are arbitrary binary chosen so no text file can match. |
| 6 | 1 | Format major version | 0 in every archive written so far. A change here would mean a structurally incompatible format, so readers treat anything else as a refusal rather than a warning. |
| 7 | 1 | Format minor version | 4 in current archives. Minor versions are backward-compatible additions, so a reader that understands 0.4 handles everything older. |
| 8 | 4 | Start header CRC-32 | Little-endian, covering exactly the twenty bytes at offsets 12 through 31. It protects the pointer that everything else depends on, so a reader can tell a damaged prefix from a damaged body before it seeks anywhere. |
| 12 | 8 | Next header offset | A little-endian 64-bit offset to the real header — counted from offset 32, the end of this signature header, not from the start of the file. In a 200246-byte archive it reads F4 0D 03 00 00 00 00 00, which is 200180, so the header begins at 200212. |
| 20 | 8 | Next header size | Little-endian 64-bit length of that header. Together with the offset it must land exactly on the end of the file: 32 plus 200180 plus 34 is 200246, the file's real size, and that arithmetic is the quickest integrity check there is. |
| 28 | 4 | Next header CRC-32 | Little-endian checksum of the header the previous two fields point at, so damage there is detected before any attempt is made to parse it. |
| 32 | variable | Packed streams | The compressed data itself, written immediately after the thirty-two byte signature header. In a solid archive this is one continuous coded stream covering many files rather than one stream per file. |
| variable | variable | Header | At offset 32 plus the next header offset: the archive's real directory — names, sizes, CRCs, timestamps, attributes and the coder chain that describes how to decode the packed streams. It is normally itself LZMA-compressed, and with header encryption enabled it is encrypted too. |
Telling it apart from its neighbours
| Easily confused with | How to tell |
|---|---|
| XZ | The one that actually causes mistakes. An .xz begins FD 37 7A 58 5A 00, so the bytes 37 7A appear at offset 1 and the ASCII '7zXZ' is plainly visible in a hex dump. A real .7z has 37 7A BC AF 27 1C at offset 0. One position apart, two unrelated formats: .7z is a multi-file archive with a directory, .xz is a single compressed stream. |
| ZIP | No bytes in common — 50 4B 03 04 against 37 7A BC AF 27 1C — but the same tool writes both and the mislabelling is constant. The structural difference is where the directory lives and what it costs: a ZIP lists and extracts one entry cheaply, while a solid .7z may have to decode gigabytes to reach one file. |
| RAR5 | The other high-ratio Windows archiver, opening 52 61 72 21 1A 07 01 00. They compete directly; the practical differences are that 7z is open and free to implement while RAR is proprietary, and that RAR has recovery records while 7z has none. |
| Self-extracting .exe | A 7-Zip SFX archive is a Windows executable with the archive appended, so offset 0 reads 4D 5A ('MZ') and the 37 7A BC AF 27 1C signature sits far into the file. It is still extractable by any 7z reader that scans for the signature, and it is why a .exe can be safely opened as an archive. |
How these files break
- Truncation, which hurts far more than it does in a ZIP. The next header offset in the first thirty-two bytes now points past the end of the file, so nothing can be listed at all — and unlike ZIP there are no per-file local headers to scan forward for, because .7z simply does not have any. Partial recovery generally means guessing the coder chain by hand.
- A failing start header CRC at offset 8. The first thirty-two bytes are damaged, and in practice that almost always means bytes were prepended or stripped rather than a bit flipping in place, because that block is tiny and rarely touched.
- Solid compression amplifying local damage. By default many files are compressed as one continuous stream, so a bad byte anywhere in a solid block destroys every file after that point in the block. Archives created with solid mode disabled trade ratio for exactly this containment.
- Encrypted headers mistaken for corruption. An archive made with header encryption cannot have its file names listed without the password, so tools report it as unreadable or show nothing at all. The archive is perfectly intact; it is declining to answer.
- Text-mode transfer. The thirty-two byte signature header survives, so the archive identifies correctly and the header pointer still resolves, and the failure appears only as a CRC error when the packed streams are actually decoded.
Where the format stands today
7z is the ratio champion of the mainstream desktop archivers, and on Windows it is what people reach for when a ZIP is too big: LZMA2 with solid blocks routinely halves what ZIP produces on source trees and document collections, and AES-256 encryption is built in rather than bolted on. The format is openly documented and the reference implementation is free, so libarchive, p7zip and most archive tools can read it. What it never became is an interchange format. It has no first-class Unix permission or symlink model, solid compression makes single-file extraction potentially very expensive, and the total absence of per-file headers means damaged archives are much harder to salvage than damaged ZIPs. On Unix the same job is done by tar.xz or tar.zst, which keep the permission model in the tar layer, and for anything that has to be opened by an unknown recipient ZIP remains the safe answer.
Open 7-Zip files on this site
Every one of these runs in your browser — the file never leaves your machine.
Related formats
Formats that are easy to confuse with 7-Zip — compare their leading bytes.