All formats

RAR (Roshal Archive)

Full nameRoshal Archive
Extensions.rar; volumes .part1.rar, .part2.rar (RAR5 and newer RAR4) or .rar, .r00, .r01 (old naming); .rev recovery volumes; .cbr (comic book)
MIME typeapplication/vnd.rar (registered), application/x-rar-compressed (common)
Typearchive, lossless compression, optional encryption
Starts withRAR5 52 61 72 21 1A 07 01 00 (Rar!\x1A\x07\x01\x00); RAR4 52 61 72 21 1A 07 00 (Rar!\x1A\x07\x00)
SpecificationRAR 5.0 archive format (RARLAB technical note)
Maintained byRARLAB (Alexander Roshal), the makers of WinRAR
Licenseproprietary; free UnRAR source for extraction, creating RAR files needs WinRAR or RAR

RAR is an archive format: it packs many files and folders into one file, compresses them, and can encrypt them with a password. It’s common for software and media downloads, comic books (.cbr) and backups. Its strengths are a good compression ratio, archives split into volumes, and a recovery record that repairs damaged archives.

RAR is proprietary. Only WinRAR and the rar command line tool from RARLAB create RAR files. Extraction is open: RARLAB publishes the UnRAR source code, which can be used in any program that extracts RAR, but not to build a RAR-compatible archiver. All open-source libraries on this site only read RAR.

When to use RAR#

RAR4 vs RAR5#

RAR has 2 incompatible archive formats. Both use the .rar extension; the signature tells them apart.

RAR4 (RAR 2.9 / 3.x / 4.x format) RAR5 (RAR 5.0 format, default since WinRAR 5.0)
Signature 52 61 72 21 1A 07 00 (7 bytes) 52 61 72 21 1A 07 01 00 (8 bytes)
Header integers fixed size, little-endian variable-length integers (vint)
Header checksum low 16 bits of CRC-32 full CRC-32
File checksum CRC-32 CRC-32 or BLAKE2sp
Compression LZSS + Huffman, PPMd, RarVM filters LZSS + Huffman, fixed filters (delta, x86, ARM)
Dictionary up to 4 MB up to 1 GB; up to 64 GB with RAR 7.0
Encryption AES-128, SHA-1 based key derivation AES-256, PBKDF2-HMAC-SHA256
File names OEM / Unicode UTF-8
Recovery recovery record, .rev volumes Reed-Solomon recovery record, .rev volumes
Readers every RAR tool most current tools; very old ones fail

Current WinRAR creates RAR5 by default and creates RAR4 only on request. Archives with a dictionary larger than 4 GB (a RAR 7.0 option) need UnRAR 7.0 or newer to extract.

File structure#

A RAR file is a signature followed by a sequence of blocks (headers). Each header may be followed by a data area, such as the compressed bytes of a file. An optional SFX module (an executable that extracts the archive) can come before the signature; readers search for the signature in the first megabyte or so.

RAR5 layout#

[SFX module]                optional, self-extracting archives
signature                   52 61 72 21 1A 07 01 00
[archive encryption header] only when file names are encrypted
main archive header
file header + data          one per file (and per volume part)
service header + data       optional: comment (CMT), NTFS streams (STM), quick open (QO)
[recovery record]           service header named RR
end of archive header

Every RAR5 header starts with the same fields. Sizes and most numbers are vint: variable-length integers with 7 bits per byte, low bits first, and the high bit set on every byte except the last.

Field Size Description
Header CRC32 4 bytes CRC-32 of everything from Header size to the end of the header
Header size vint size of the header after this field (max 2 MB)
Header type vint 1 main archive, 2 file, 3 service, 4 archive encryption, 5 end of archive
Header flags vint 0x0001 extra area present, 0x0002 data area present, 0x0004 skip if unknown, 0x0008 / 0x0010 data continues from previous / in next volume
Extra area size vint if flag 0x0001
Data size vint if flag 0x0002; for a file, the packed size

The start of a typical RAR5 file:

52 61 72 21 1A 07 01 00   signature "Rar!\x1A\x07\x01\x00"
xx xx xx xx               header CRC32
0A                        header size (vint): 10 bytes follow
01                        header type 1: main archive header
05                        header flags: extra area present, skip if unknown
06                        extra area size: 6
00                        archive flags: not a volume, not solid
...                       extra area (locator record), then file headers (type 2)

Main archive header flags: 0x0001 volume, 0x0002 volume number present (all volumes except the first), 0x0004 solid, 0x0008 recovery record present, 0x0010 locked (can’t be modified).

File header fields after the common part: file flags (directory, mtime present, CRC32 present, unknown size), unpacked size, attributes, modification time, CRC-32, compression info, host OS (0 Windows, 1 Unix), and the UTF-8 name. The compression info vint holds the method in bits 7-9 (0 = store, 1-5 = fastest to best) and the dictionary size in bits 10-14. Extra records in a file header add encryption parameters, a BLAKE2sp hash, high-precision times, symlinks and hard links, and Unix owner names.

RAR4 layout#

RAR4 uses fixed-size fields in little-endian order. Every block starts with a 7-byte header:

Field Size Description
HEAD_CRC 2 bytes low 16 bits of the CRC-32 of the header
HEAD_TYPE 1 byte 0x72 marker, 0x73 archive header, 0x74 file, 0x7A service (comment, recovery record), 0x7B end of archive
HEAD_FLAGS 2 bytes block flags; 0x8000 means an ADD_SIZE field and a data area follow
HEAD_SIZE 2 bytes size of the header including these 7 bytes
ADD_SIZE 4 bytes size of the data area, if flag 0x8000

The 7-byte signature is itself a marker block (0x72). A file block (0x74) stores packed size, unpacked size, host OS, CRC-32, DOS date and time, the version needed to extract, the method (0x30 store to 0x35 best), name length, attributes, the name, and an 8-byte salt for encrypted files. Files over 4 GB add 32-bit high parts of the sizes.

Solid archives#

In a solid archive the files are compressed as one continuous stream, so similar files share the dictionary and compress much better. The cost: extracting one file means decompressing all files before it, and damage in one place breaks every file after it. Libraries that extract solid archives are much faster when they process entries in order.

Volumes#

A large archive can be split into volumes of a fixed size. RAR5 archives and most newer RAR4 archives name them name.part1.rar, name.part2.rar; old RAR4 archives use name.rar, name.r00, name.r01. Open the first volume to extract: tools find the next ones by name. A file that spans volumes has a file header in each volume with the “continues” flags set.

Encryption#

RAR encrypts file data, and optionally all headers too (WinRAR’s “Encrypt file names”). Without the password, an archive with encrypted headers doesn’t even show its file list. RAR5 uses AES-256 in CBC mode with a key from PBKDF2-HMAC-SHA256 (215 iterations by default), and stores a check value so a wrong password is detected before extraction. RAR4 uses AES-128.

Recovery record and recovery volumes#

A recovery record is extra redundancy data (a percentage of the archive size) stored inside the archive. WinRAR’s “Repair” command uses it to fix damaged sectors. Recovery volumes (.rev) do the same for whole missing volumes. Extraction libraries ignore both.

Specifications and documentation#

Software that opens RAR files#

SoftwareWindowsmacOSLinuxWebCanNotes
SumatraPDF✓viewfree, open source; shows images inside .rar and .cbr comic books, doesn't extract other files
WinRAR✓view, edit, create, convertcommercial (trial); the only GUI that creates RAR
RAR command line✓✓✓create, editcommercial, rar for macOS, Linux and FreeBSD; unrar is free
File Explorer✓viewbuilt into Windows 11 (23H2 and newer), extract only, no encrypted archives
7-Zip✓✓✓viewfree, open source; extracts RAR4 and RAR5 (command line 7zz on macOS and Linux)
NanaZip✓viewfree, open source 7-Zip fork for Windows 11
PeaZip✓✓✓viewfree, open source
Bandizip✓✓viewfree edition, extracts RAR5
The Unarchiver✓viewfree; unar command line also for Linux
Keka✓viewfree (paid in the Mac App Store)
Ark✓viewfree, open source, KDE; uses unrar or unar
File Roller✓viewfree, open source, GNOME Archive Manager
RAR for Androidview, createby RARLAB, free with ads. Also on Android
ZArchiverviewfree. Also on Android
ezyZip✓viewextracts in the browser

Libraries#

Open-source libraries extract RAR files; none create them. See all RAR libraries for a comparison.

C/C++libarchive, UnRAR library
C#SharpCompress
Javajunrar
Gorardecode
Pythonrarfile
Rubyffi-libarchive
Rustunrar
PHPrar extension