7Z File Documentation


Summary

A 7-Zip Compressed File is a high-compression archive that bundles one or more files into a single .7z, using LZMA/LZMA2 by default and optional AES-256 password protection. It was created by Igor Pavlov in 1999, begins with the signature 37 7A BC AF 27 1C, and its MIME type is application/x-7z-compressed. Unlike proprietary RAR, the 7z format is open source, so free tools such as 7-Zip, Keka and p7zip both create and extract it.

Technical details

FeatureValue
Full name7-Zip Archive
File extension.7z
MIME typeapplication/x-7z-compressed
Format typeOpen-source compressed archive container
DeveloperIgor Pavlov (7-Zip)
Introduced1999
Open standardYes — format and reference tool are open source (LGPL)
Byte orderLittle-endian
Default compressionLZMA / LZMA2
Other methodsBZip2, PPMd, Deflate; BCJ / delta pre-filters
Solid compressionYes — files packed as one stream for higher ratio
EncryptionAES-256; optional header (filename) encryption
Header locationStored at the END of the file
Recovery recordNo (unlike RAR)
Multi-volumeYes — .7z.001, .7z.002, …
Magic number37 7A BC AF 27 1C (“7z” + BC AF 27 1C)
Creates & extracts7-Zip, NanaZip, PeaZip, Keka, p7zip, WinRAR (extract)
Related extensions.zip, .rar, .tar, .gz, .xz, .bz2
Specification7-zip.org/7z.html
File signature (magic bytes)
37 7A BC AF 27 1C

Offset 0, 6 bytes. The first two, 37 7A, are ASCII “7z”; the remaining four (BC AF 27 1C) are a fixed constant. Immediately after come a 2-byte format version and a CRC over the start header. Unusually, the main header (the file index) is stored at the END of the archive, and the start header holds a 64-bit offset and size pointing to it. Unlike RAR, the 7z format is open source, so the same free tools both create and extract it.

What is a 7z file?

A .7z file is the native archive format of 7-Zip, the free, open-source file archiver written by Igor Pavlov and first released in 1999. Like ZIP and RAR, it bundles many files and folders into one compressed container, but 7z is built for high compression: its default LZMA/LZMA2 method typically produces noticeably smaller archives than ZIP, and it supports solid compression, AES-256 encryption, very large files and Unicode names. Its MIME type is application/x-7z-compressed.

The defining contrast with RAR is openness. Both the 7z format and the 7-Zip tool are open source, so any compatible archiver can both create and open .7z files — there is no “only one program can make it” restriction. What makes 7z technically interesting is its architecture: a container that stores its own table of contents at the end of the file, and a flexible coder pipeline that lets several compression and filter methods be chained per group of files. The sections below follow the layout from the six signature bytes to the header, then explain the compression methods and the pipeline that ties them together.

The overall layout: signature header, packed streams, end header

A 7z file has an unusual three-part shape. The compressed data sits in the middle, and the index that describes it is written last, at the end of the file:

┌───────────────────────────────┐  offset 0
│ Signature header (32 bytes)   │  37 7A BC AF 27 1C + version + start-header info
├───────────────────────────────┤
│ Packed streams                │  the actual compressed data (one or more streams)
│   ...                         │
├───────────────────────────────┤
│ Header (a.k.a. end header)    │  StreamsInfo: coders, folders, sizes, CRCs, names
└───────────────────────────────┘  end of file

The 32-byte signature header at offset 0 contains the 6-byte magic 37 7A BC AF 27 1C, a 2-byte format version, a CRC over the next field, and then the start header: a 64-bit offset and a 64-bit size that locate the main header, plus a CRC of that main header. Because those two numbers point to a position near the end of the file, a reader opens a 7z by seeking to the very start, reading the start header, then jumping to the end to read the actual index. Writing the header last lets the compressor stream data out without knowing the final sizes in advance, then record all the offsets, sizes and checksums once compression has finished. The main header can itself be compressed and even encrypted.

The header: StreamsInfo, folders and coders

The main header holds the archive’s metadata in a structure the specification calls StreamsInfo, which is where 7z’s design differs most from ZIP. It does not simply list “file → compressed bytes.” Instead it describes:

  • PackInfo — where the packed streams sit in the file and how large each is.
  • UnpackInfo (CodersInfo) — a set of folders, where a “folder” in 7z terminology is not a directory but a block of data compressed together as a unit. Each folder lists the coders (compression or filter methods) applied to it and how they are wired together.
  • SubStreamsInfo — how each folder’s decompressed output is divided back into individual files, with per-file sizes and CRC-32 checksums.

A separate FilesInfo section records the file names (UTF-16), attributes, timestamps and empty-file/empty-folder markers. This indirection, files grouped into folders, folders processed by coders, is what enables solid compression and the coder pipeline described below. A single folder can hold hundreds of files compressed as one continuous stream; the SubStreamsInfo then says where each file ends within that stream.

LZMA and LZMA2 compression

The default 7z coder is LZMA (the Lempel-Ziv-Markov chain algorithm), Pavlov’s own compression method and the main reason 7z archives are small. LZMA combines an LZ77-style dictionary matcher (replacing repeated byte sequences with length-distance references) with a range coder driven by context models that adapt to the data. It supports large dictionaries (up to 1 GB, commonly 64 MB), which lets it find matches across long distances. LZMA generally beats ZIP’s Deflate on ratio, at the cost of slower, more memory-hungry compression.

LZMA2 is a wrapper around LZMA that splits the data into independently described chunks, each either LZMA-compressed or stored uncompressed. This adds two practical benefits: it allows multi-threaded compression (different chunks on different cores) and it lets the encoder fall back to storing incompressible chunks raw instead of expanding them. LZMA2 is the usual default for solid, multi-threaded 7z archives. The container can also store other methods, BZip2, PPMd (strong on text), and Deflate, selected per folder.

Solid compression

By grouping many files into a single folder and compressing them as one stream, 7z performs solid compression: the dictionary built while packing one file carries over to the next, so repeated content shared across files (common in source trees or many similar documents) is encoded once. This is a large part of why 7z ratios can far exceed ZIP, which compresses each entry separately. The cost is the same as with any solid archive: to extract one file, the decompressor must process the folder from its start up to that file, because the LZMA state is sequential. 7-Zip lets you cap the solid block size to trade some ratio for faster single-file extraction.

BCJ and delta filters

Before the main compressor runs, 7z can apply a reversible pre-filter that rearranges the data into a form the compressor handles better; the filter is undone on extraction. Two families matter. The BCJ filters (branch-call-jump) target executable machine code: in a compiled binary, CALL and JUMP instructions carry relative target addresses that look random to a compressor, so BCJ converts them to absolute addresses, which repeat far more and compress better. There are variants per CPU architecture (x86, ARM, ARM64, PowerPC, SPARC). The delta filter replaces each byte with its difference from the byte a fixed distance earlier, which helps regular data such as uncompressed audio or simple bitmaps where adjacent samples are similar. These filters add nothing on their own; they exist to feed better-structured data into LZMA.

The coder pipeline concept

The filters and compressors combine through 7z’s coder pipeline. Each folder in the header defines one or more coders and how their inputs and outputs connect, so the data flows through a chain. A typical executable-heavy archive uses a two-stage pipeline:

original bytes → [ BCJ2 filter ] → [ LZMA2 ] → packed stream
extraction:     packed stream → [ LZMA2 decode ] → [ BCJ2 undo ] → original bytes

Encryption is itself just another coder in this graph: when a password is set, an AES-256 coder is inserted so that the LZMA output is encrypted before being written. Because the pipeline is data-described in the header rather than fixed, 7z can express arbitrary chains, filter, then compress, then encrypt, and a decoder simply runs the chain in reverse using the coder list stored for that folder. This flexibility is what lets one container format support many methods without a new file format for each.

AES-256 encryption and split volumes

7z encrypts with AES-256 in CBC mode, deriving the key from the password with a slow SHA-256-based key-derivation function to slow brute-force attacks. As with RAR, there are two levels: encrypting file contents only (names stay visible in the header), or enabling header encryption, which encrypts the main header so that even the list of file names and sizes is hidden. Large archives can be split into volumes named archive.7z.001, archive.7z.002, and so on; these are a raw byte-split of the single archive, so all parts must be present and you open the .001 file to extract. Note one gap versus RAR: 7z has no recovery record, so a damaged 7z generally cannot be repaired and must be re-downloaded.

A note on security

The 7z format is passive data, but like any archive it is a delivery wrapper: it hides the true types of the files inside until extraction, and AES-256 password protection can be used deliberately to keep malicious contents from being scanned. Treat an unexpected password-protected .7z with caution and scan extracted files before running them. Self-extracting 7z archives are .exe files that run code by design, so launch them only from trusted sources.

Frequently asked questions

Can I create a 7z file for free?

Yes. Unlike RAR, the 7z format is open source, so free tools, 7-Zip and NanaZip on Windows, Keka on macOS, p7zip on Linux, both create and extract .7z, including with AES-256 password protection.

Why is the 7z header stored at the end of the file?

Writing the index last lets the compressor stream data out before it knows the final compressed sizes, offsets and checksums, then record them all once compression finishes. The 32-byte start header at offset 0 holds a 64-bit pointer and size that locate that end header, so a reader seeks to the start, then jumps to the end to read the file list.

My 7z archive is corrupt — can I recover it?

Usually not. 7z has no recovery record like RAR, so there is no built-in redundancy to reconstruct damaged bytes. Run 7-Zip’s Test (CRC) to confirm the damage, check that a split archive has all its .00N parts, and otherwise re-download the file.

References