Inside a RAR File: Signature, Structure and MIME Type

November 08, 2026 · RAR.now Editorial · RAR Essentials

Learn how RAR is identified and what its internal components mean.

Signature Identification

Every RAR file opens with a fixed seven-byte sequence that identifies the format and the major version. This marker is the first thing a parser, file manager, or forensic tool must check before interpreting any subsequent data.

  • RAR 1.x–4.x (classic format): 52 61 72 21 1A 07 00
    ASCII representation: Rar!\x1a\x07\x00
  • RAR 5.x (revised format): 52 61 72 21 1A 07 01
    ASCII representation: Rar!\x1a\x07\x01

The two signatures diverge at the seventh byte: 0x00 for legacy archives, 0x01 for RAR5. This single byte dictates the entire block structure that follows. RAR5 is not backward compatible with earlier parsers, and a tool designed for one format will reject or misparse the other. The RARLAB technical note (rarfile.txt) treats RAR5 as a separate container, not an extension of the classic format.

Validation check: Open any .rar file in a hex editor. If bytes 0–6 read 52 61 72 21 1A 07 00, the archive uses the classic block layout. If the seventh byte is 0x01, the archive is RAR5. No other compression format shares this exact seven-byte prefix, which makes it a reliable forensic marker even when file extensions are missing or misleading.

Block-Based Architecture

RAR does not use a central directory at the end of the file. Instead, data is organized as a sequential chain of variable-length blocks. Each block carries a header that declares its type, total size, and an optional integrity check. The parser must walk this chain from the signature to the end-of-archive marker; there is no index to skip ahead.

Classic Block Header (Pre-RAR5)

Every block in a classic RAR archive begins with a fixed seven-byte header:

Offset Size (bytes) Field Purpose
0 2 HEAD_CRC CRC16 of the header, or of the entire block depending on flags
2 1 HEAD_TYPE Block type identifier (see table below)
3 2 HEAD_FLAGS Bitfield for encryption, solid mode, comment presence
5 2 HEAD_SIZE Total block size including this header

HEAD_TYPE values:

Value Meaning
0x72 File block — contains compressed file data and per-file metadata
0x73 Service block — virtual file storing archive-level data such as the main archive header or recovery records
0x74 Subblock — supplementary data attached to a preceding block, often used for file comments
0x75 End of archive marker — no further blocks follow

RAR5 Block Header Differences

RAR5 discards the fixed seven-byte header in favor of a variable-length structure. A base header occupies at least seven bytes but extends based on flags set within it. The CRC field moves to the end of the block rather than the beginning. The block type field uses different numeric values from the classic format, and encryption metadata is integrated directly into the header flags instead of residing in a separate subblock.

Hard design constraint: A parser must commit to one header format immediately after reading the seventh byte of the signature. The two block layouts cannot be mixed within a single archive, and no fallback mechanism exists.

Block Types and Their Internal Layout

Main Archive Header

The first block following the signature is a service block (HEAD_TYPE = 0x73) that functions as the main archive header. It is not a file entry. This block carries archive-wide metadata:

  • Volume number, for multi-part archives
  • Encryption algorithm identifier, when password protection is active
  • Optional archive comment text
  • A flag indicating whether a recovery record is present

If this block is missing or its HEAD_CRC fails validation, the entire archive may become unreadable even when individual file blocks remain intact downstream.

File Block

Each compressed file occupies one file block (HEAD_TYPE = 0x72). The header extends beyond the base seven bytes with file-specific fields:

Offset Size (bytes) Field Notes
7 4 PACK_SIZE Compressed size of the file data
11 4 UNP_SIZE Uncompressed size
15 1 HOST_OS 0=MS-DOS, 1=OS/2, 2=Windows, 3=Unix
16 4 FILE_CRC32 CRC32 of the uncompressed file data
20 4 FILE_TIME DOS-format date and time stamp
24 1 METHOD 0=stored, 1–5=compression levels
25 2 FILENAMESIZE Length of the file name in bytes
27 variable FILE_NAME Null-terminated, encoding depends on HOST_OS

Compressed data follows the header immediately, with no separator or padding. The parser reads exactly PACK_SIZE bytes after the header to obtain the compressed stream.

Encoding limitation: In the classic format, the file name is stored in the local 8-bit encoding of the creating system. No universal UTF-8 field exists. RAR5 addresses this by adding explicit UTF-8 name storage.

End of Archive Block

A single block with HEAD_TYPE = 0x75 and HEAD_SIZE = 0x0007 marks the end of the archive. In multi-volume sets, this block may contain the file name of the next volume. Any data following this block is not part of the archive and must be ignored by conforming parsers.

MIME Type and Detection

The IANA-registered MIME type for RAR archives is:

  • application/vnd.rar

This is the canonical identifier for HTTP Content-Type headers, email attachments, and file-type detection libraries. The legacy string application/x-rar-compressed persists in some older systems but is not the registered value.

Detection behavior by environment:

Environment Mechanism
Web servers Should serve application/vnd.rar per RFC
Linux file Matches on the seven-byte magic number, not MIME
macOS Uses magic bytes with .rar extension fallback
Windows Relies on .rar extension and registered MIME

The .rar extension is the only registered file suffix, but competent tools override extension-based detection with the magic-byte check. A file starting with 52 61 72 21 1A 07 is identified as RAR regardless of its name.

Structural Edge Cases

Solid Archives

When the solid flag (HEAD_FLAGS bit 0x0100) is set, multiple file blocks share a single compression dictionary. The first file block initializes the dictionary, and every subsequent file block depends on the state left by its predecessor. Corruption in any file block of a solid stream prevents extraction of all files that follow it, even if their individual FILE_CRC32 values are valid.

Recovery Records

Recovery data is stored as a service block (HEAD_TYPE = 0x73) with a subtype that identifies it as Reed-Solomon parity. This block sits after the last file block but before the end-of-archive marker. Parsers that stop reading at the final file block will skip recovery data entirely, losing the ability to repair damage elsewhere in the archive.

Multi-Volume Archives

Each volume in a multi-volume set begins with the same RAR signature. The main archive header in the first volume records the total file count. Subsequent volumes may contain file blocks that are split across volume boundaries. The volume number is encoded in the main archive header’s flags. A parser must check this field to determine whether it is reading the first volume or a continuation, and must handle file blocks that begin in one physical file and end in another.

Structural Verification Without Extraction

A RAR file can be validated for structural integrity without decompressing any data:

  1. Read bytes 0–6 and confirm the magic number matches one of the two valid signatures.
  2. Parse the main archive header block and verify its HEAD_CRC.
  3. Walk each subsequent block, checking HEAD_CRC on every header.
  4. For each file block, record the FILE_CRC32 value for post-extraction verification.
  5. Confirm that an end-of-archive block (0x75) is present and that no blocks follow it.

A HEAD_CRC failure indicates corruption in the block metadata itself. A FILE_CRC32 failure means the compressed data was read without error but the decompressed output does not match the original file. These two checks are independent and diagnose different failure modes.

Reference: RARLAB Technical Note, https://www.rarlab.com/technote.htm