CBT (Comic Book TAR archive)
| Full name | Comic Book TAR archive |
|---|---|
| Extensions | .cbt |
| MIME type | application/x-cbt (not registered with IANA) |
| Type | container (TAR archive of images, no compression) |
| Starts with | the name of the first file; ustar at offset 257 (75 73 74 61 72) |
| Specification | no formal spec; container is POSIX tar / pax, metadata is ComicInfo.xml |
| Maintained by | no owner (de facto standard); tar is a POSIX standard |
| License | open, royalty-free |
A CBT file is a TAR archive that holds the pages of a comic book as image files, usually JPEG or PNG. A reader reads the archive, sorts the image names and shows them in that order. Rename it to .tar and any tar tool extracts it.
TAR doesn’t compress, which costs nothing for comics: JPEG and PNG pages are already compressed. CBT is simple to write (every Unix system has tar) but rare in practice. TAR has no index, so a reader must scan the archive to find a page. Most desktop readers support CBT; some mobile apps and comic servers don’t.
When to use CBT#
- Use when you produce comics with Unix tools and want zero dependencies:
tar -cf book.cbt pages/is enough. - Use for streaming creation: a tar can be written sequentially to a pipe or socket without seeking.
- Avoid for distribution: CBZ has the same size (with stored entries), better reader support and fast random access.
- Avoid compressing it (
.tar.gzrenamed to.cbt): most readers expect a plain tar.
File structure#
A CBT is a plain TAR 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.
Bone 01.cbt
├── ComicInfo.xml optional metadata
├── 001.jpg cover
├── 002.jpg
└── ...
A tar archive is a sequence of 512-byte blocks: a header block for each file, followed by the file data padded to a multiple of 512 bytes. Two zero blocks mark the end.
30 30 31 2E 6A 70 67 00 ... offset 0: file name "001.jpg" (100 bytes)
30 30 30 30 36 34 34 00 offset 100: mode "0000644" (octal text)
... uid, gid
30 30 30 30 30 37 33 31 34 34 31 00 offset 124: size in octal ("00000731441" = 242465 bytes)
... mtime, checksum
30 offset 156: type flag '0' = regular file
...
75 73 74 61 72 00 30 30 offset 257: "ustar\0" + version "00" (POSIX ustar)
... owner, group, prefix (up to offset 512)
FF D8 FF E0 ... offset 512: JPEG data, padded to a 512-byte boundary
| Header field | Offset | Size | Notes |
|---|---|---|---|
| name | 0 | 100 | file path; longer names use the prefix field (ustar), a pax x header or GNU L entry |
| size | 124 | 12 | octal ASCII |
| typeflag | 156 | 1 | 0 file, 5 directory, x pax extended header, L GNU long name |
| magic | 257 | 6 | ustar\0 (POSIX) or ustar (GNU) |
| prefix | 345 | 155 | directory part of long paths (ustar) |
The container details (pax headers, GNU extensions) are on the TAR format page.
Reading pages from a tar#
TAR has no central directory. To list pages, a reader walks all headers: for each one it reads 512 bytes and seeks past the data. With uncompressed tar that is fast (one seek per file), and readers build an index of name to offset once, then read pages directly. A gzip-compressed tar would need full decompression for every scan, which is why CBT should stay uncompressed.
Entries to skip#
Besides the usual __MACOSX and dotfiles, tar archives created on macOS contain AppleDouble files (._001.jpg) with extended attributes, and pax archives contain PaxHeader entries when a tool doesn’t understand them. Libraries handle pax headers; filter ._* names yourself.
Creating a CBT#
# GNU tar or bsdtar; run inside the folder so paths have no prefix
cd "Bone 01" && tar -cf "../Bone 01.cbt" *
# macOS: don't store extended attributes as ._ files
COPYFILE_DISABLE=1 tar -cf "Bone 01.cbt" -C "Bone 01" .
# 7-Zip
7z a -ttar "Bone 01.cbt" "./Bone 01/*"
Zero-pad page numbers (001.jpg) so readers without natural sort keep the order.
Converting#
- CBT to CBZ:
mkdir p && tar -xf book.cbt -C p && cd p && zip -0 -r ../book.cbz ., orcomicbox -z book.cbt. Nothing is re-encoded. - CBZ to CBT: unzip, then
tar -cf. - CBT to EPUB/PDF: convert to CBZ first; Calibre reads CBZ, CBR and CB7 but not CBT.
Specifications and documentation#
- pax / ustar format (POSIX, The Open Group): the standard tar header layout, in the pax utility description
- GNU tar manual: tar archive format: GNU extensions
- ComicInfo.xml documentation (Anansi Project): the metadata schema
- Comic book archive on Wikipedia
Software that opens CBT files#
| Software | Windows | macOS | Linux | Web | Can | Notes |
|---|---|---|---|---|---|---|
| SumatraPDF | ✓ | view | free, open source; reads ComicInfo.xml, manga (right-to-left) mode | |||
| CDisplayEx | ✓ | view | free comic reader | |||
| MComix | ✓ | ✓ | view | free, open source | ||
| Kavita | ✓ | ✓ | ✓ | ✓ | view | free, open source reading server |
| Okular | ✓ | ✓ | view | free, open source document viewer | ||
| 7-Zip | ✓ | ✓ | create, convert | free, open source | ||
| tar | ✓ | ✓ | ✓ | create, convert | built into Linux, macOS (bsdtar) and Windows 10+ (tar.exe) |
Libraries#
Open-source libraries that read and write CBT files, with comic-specific examples (page order, cover, ComicInfo.xml, creating a CBT). See all CBT libraries; general TAR information is on the TAR page.
| C/C++ | libarchive |
|---|---|
| C# | SharpCompress, System.Formats.Tar |
| Java | Commons Compress |
| Go | archive/tar |
| Python | comicbox, tarfile |
| Ruby | ffi-libarchive, minitar |
| Rust | tar |
| PHP | PharData |