ByteScope

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

0x00000000377ABCAF271C7z··'·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

OffsetLengthFieldMeaning
06Signature37 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.
61Format major version0 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.
71Format minor version4 in current archives. Minor versions are backward-compatible additions, so a reader that understands 0.4 handles everything older.
84Start header CRC-32Little-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.
128Next header offsetA 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.
208Next header sizeLittle-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.
284Next header CRC-32Little-endian checksum of the header the previous two fields point at, so damage there is detected before any attempt is made to parse it.
32variablePacked streamsThe 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.
variablevariableHeaderAt 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 withHow to tell
XZThe 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.
ZIPNo 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.
RAR5The 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 .exeA 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.

FormatFirst bytesExtension
ZIP50 4B 03 04.zip
RAR552 61 72 21 1A 07.rar
XZFD 37 7A 58 5A 00.xz
Zstandard28 B5 2F FD.zst

Frequently asked questions

What is a magic number in a file?

The first few bytes of a file, which identify its format regardless of what the name says. A PNG always starts with 89 50 4E 47; a ZIP with 50 4B 03 04. Operating systems, browsers and the file command all read these bytes rather than trusting the extension, which is why renaming a file does not change what it actually is.

How do I check a file's magic number myself?

On macOS or Linux, xxd -l 16 yourfile prints the first 16 bytes; on Windows, Format-Hex -Path yourfile -Count 16 in PowerShell. Or drop the file into the File Type Identifier on this site, which reads the bytes locally and names the format for you — nothing is uploaded.

Why do two formats share the same magic number?

Because one is built on the other. Every docx, xlsx, pptx, apk, jar and epub begins with the ZIP signature, since all of them are ZIP archives underneath; telling them apart means looking at the entries inside. Java class files and macOS universal binaries both start with CA FE BA BE and are distinguished by the field that follows.

Can a file have no magic number at all?

Yes. Text-based formats — XML, HTML, JSON, SVG, CSV — have no fixed byte signature, so they are recognized structurally instead: a leading <?xml declaration, a <svg element, or a { followed by a quoted key. That detection is a good guess rather than a certainty, which is why this reference marks those formats as probe-detected.

Does a matching magic number mean the file is safe?

No. It tells you what the format is, not whether the contents are harmless — a genuine PDF or docx can still carry a malicious payload. Identifying the true type is a useful first check, especially when the extension disagrees with the bytes, but it is not a malware scan.

Have a file that might be in the 7-Zip format? Identify it with the File Type Identifier — it reads the magic number locally, nothing is uploaded. Or browse all formats.