CBR (Comic Book RAR archive)
| Full name | Comic Book RAR archive |
|---|---|
| Extensions | .cbr |
| MIME type | application/vnd.comicbook-rar (registered with IANA) |
| Type | container (RAR archive of images) |
| Starts with | 52 61 72 21 1A 07 00 (Rar! RAR 1.5-4.x) or 52 61 72 21 1A 07 01 00 (RAR 5.0+) |
| Specification | no formal spec; container is RAR (RARLAB technote), metadata is ComicInfo.xml |
| Maintained by | no owner (de facto standard); RAR format by RARLAB |
| License | RAR is proprietary: free to extract (UnRAR source license), creating RAR needs WinRAR |
A CBR file is a RAR archive that holds the pages of a comic book as image files, usually JPEG or PNG. A reader opens the archive, sorts the image names and shows them in that order. Rename it to .rar and WinRAR, 7-Zip or unrar extracts it.
CBR was common for scanned comics shared online, because WinRAR was popular and RAR compressed slightly better than ZIP for some content. For comic pages (already compressed JPEG/PNG) the size difference is negligible. Readers support CBR well, but open-source software can only read RAR, never write it: convert CBR to CBZ when you edit or re-tag a comic.
When to use CBR#
- Use only to read existing files: every comic reader opens CBR.
- Avoid for new comics: creating RAR needs WinRAR (commercial), and there are no open-source RAR writers. Use CBZ.
- Avoid for metadata editing: tools like ComicTagger and comicbox can’t write into RAR, so they convert to CBZ first.
- Avoid solid RAR archives in readers and servers: opening page 100 means decompressing pages 1-99 first.
File structure#
A CBR is a RAR archive. The page and metadata rules are the same as for CBZ: every image entry is a page, pages are sorted by name (natural sort in most readers), the first page is the cover, and an optional ComicInfo.xml carries metadata. See CBZ file structure for the rules, the sort-order pitfalls and the ComicInfo.xml schema.
Saga 001.cbr
├── ComicInfo.xml optional metadata
├── Saga 001 - 000.jpg cover
├── Saga 001 - 001.jpg
└── ...
RAR4 and RAR5#
RAR has two incompatible archive versions. Check the signature before choosing a library: some older libraries only read RAR4.
| Version | Signature | Created by | Notes |
|---|---|---|---|
| RAR 1.5-4.x (RAR4) | 52 61 72 21 1A 07 00 |
WinRAR before 5.0, or WinRAR 5+ with the RAR4 option | most CBR files from the 2000s and 2010s |
| RAR 5.0+ (RAR5) | 52 61 72 21 1A 07 01 00 |
WinRAR 5.0 and later (default) | different header layout, larger dictionary, BLAKE2 checksums |
52 61 72 21 1A 07 01 00 RAR5 signature "Rar!\x1a\x07\x01\x00"
xx xx xx xx CRC-32 of the main archive header
xx header size (variable-length integer)
01 header type: 1 = main archive header
... file headers (type 2), each followed by the packed data
The RAR container details are on the RAR format page.
Solid archives#
In a solid RAR, all files are compressed as one continuous stream. This compresses better when files are similar, but a reader can’t decompress page 50 without decompressing pages 1-49 first. Comic readers either extract the whole archive to a temporary folder or decompress it into memory once. Non-solid archives allow direct access to each page.
CBR files that are really ZIP#
Many files named .cbr are ZIP archives (and some .cbz files are RAR archives), because people renamed the extension. Good readers detect the type from the first bytes (Rar! or PK\x03\x04), not the extension. Do the same in your code: check the signature, then pick the RAR or ZIP library.
Converting CBR to CBZ#
Converting is lossless: extract the pages and put them into a ZIP archive. Nothing is re-encoded.
# with unrar and zip
mkdir pages && unrar e -idq "Saga 001.cbr" pages/
cd pages && zip -0 -r "../Saga 001.cbz" . && cd .. && rm -r pages
# with 7-Zip (needs the RAR codec, included in the official 7-Zip builds)
7z x -opages "Saga 001.cbr" && 7z a -tzip -mx=0 "Saga 001.cbz" ./pages/*
# with comicbox (keeps metadata)
comicbox -z "Saga 001.cbr"
ComicTagger also converts CBR to CBZ. Keep the folder structure and the file names: they define the page order.
Specifications and documentation#
- RAR 5.0 archive format (RARLAB): headers of the container; the compression algorithm is not documented
- UnRAR source code (RARLAB): reference decompressor, freeware license
- ComicInfo.xml documentation (Anansi Project): the metadata schema
- application/vnd.comicbook-rar IANA media type registration
- Comic book archive on Wikipedia
Software that opens CBR files#
| Software | Windows | macOS | Linux | Web | Can | Notes |
|---|---|---|---|---|---|---|
| SumatraPDF | ✓ | view | free, open source; RAR4 and RAR5, reads ComicInfo.xml, manga (right-to-left) mode | |||
| CDisplayEx | ✓ | view | free comic reader. Also on Android | |||
| YACReader | ✓ | ✓ | ✓ | view | free, open source (GPL-3.0); RAR4 and RAR5. Also on Android and iOS | |
| MComix | ✓ | ✓ | view | free, open source; needs unrar or libunrar | ||
| ComicRack Community Edition | ✓ | view, convert | free, open source; converts to CBZ to write metadata | |||
| Komga | ✓ | ✓ | ✓ | ✓ | view | free, open source comic server |
| Kavita | ✓ | ✓ | ✓ | ✓ | view | free, open source reading server; RAR and RAR5 |
| Calibre | ✓ | ✓ | ✓ | view, convert | free, open source; converts CBR to EPUB, MOBI, PDF | |
| Okular | ✓ | ✓ | view | free, open source; needs unrar for CBR | ||
| Panels | ✓ | view | free with paid premium features. Also on iOS | |||
| Simple Comic | ✓ | view | free, open source | |||
| ComicTagger | ✓ | ✓ | ✓ | convert | free, open source; converts CBR to CBZ to tag it | |
| WinRAR | ✓ | create, convert | commercial (trial); the only program that creates RAR archives | |||
| 7-Zip | ✓ | ✓ | convert | free, open source; extracts RAR4 and RAR5 |
Libraries#
Open-source libraries that read CBR files, with comic-specific examples (page order, cover, ComicInfo.xml, converting to CBZ). No open-source library writes RAR. See all CBR libraries; general RAR information is on the RAR page.
| C/C++ | libarchive, UnRAR |
|---|---|
| C# | SharpCompress |
| Java | junrar |
| Go | archives, rardecode |
| Python | comicbox, rarfile |
| Ruby | ffi-libarchive |
| Rust | compress-tools, unrar |