MOBI (Mobipocket and Kindle e-books)
| Full name | Mobipocket e-book; Amazon Kindle formats AZW, AZW3 (KF8) |
|---|---|
| Extensions | .mobi, .azw, .azw3, .prc; related: .azw4 (Print Replica), .pdb (PalmDOC) |
| MIME type | application/x-mobipocket-ebook; application/vnd.amazon.ebook (AZW), application/vnd.amazon.mobi8-ebook (AZW3) |
| Type | e-book, reflowable HTML text in a Palm Database container |
| Starts with | 32-byte book name, then BOOKMOBI at offset 60 (TEXtREAd for PalmDOC) |
| Specification | no official public specification; documented by the MobileRead wiki |
| Maintained by | Amazon (proprietary) |
| License | proprietary, undocumented |
MOBI is the e-book format of Mobipocket, which Amazon bought and turned into the Kindle format. A MOBI file is a Palm Database (PDB) file: a list of records that hold compressed HTML text, images and indexes, with metadata in a MOBI header and EXTH records. AZW is a MOBI file sold by Amazon, usually with Amazon DRM. AZW3, also called KF8 (Kindle Format 8), uses the same container but stores HTML5 and CSS3 content, embedded fonts and fixed layout.
MOBI is a legacy format. Amazon now takes EPUB for publishing (Kindle Direct Publishing) and for personal documents (Send to Kindle no longer accepts MOBI), and books bought on current Kindles are delivered in KFX, a different format. Kindle e-readers still open sideloaded .mobi and .azw3 files copied over USB, which is the main reason to create these files today.
When to use MOBI#
- Use AZW3 when you sideload your own books onto a Kindle e-reader over USB: it keeps CSS, fonts and the table of contents.
- Use a reader that supports MOBI to open old Mobipocket and Kindle files you already have.
- Avoid for publishing: Amazon KDP and Send to Kindle take EPUB and convert it themselves.
- Avoid the old MOBI 6 format (
.mobiwithout KF8) for new books: it supports only basic HTML 3.2-like formatting, no CSS.
File structure#
A MOBI file has three layers: the Palm Database container, the PalmDOC header with the MOBI and EXTH headers in record 0, and the content records. All integers are big-endian.
PDB header (78 bytes) name, dates, type "BOOK", creator "MOBI", record count
record list (8 bytes per rec) offset of each record in the file
record 0 PalmDOC header, MOBI header, EXTH header, full title
records 1..N compressed text (HTML), 4096 bytes uncompressed each
... index records (NCX/TOC, skeleton, fragments for KF8)
first image record ... images (JPEG, GIF, PNG) as raw files, cover included
FLIS, FCIS, DATP, EOF helper records
PDB header#
| Offset | Size | Field |
|---|---|---|
| 0 | 32 | database name: NUL-terminated short title |
| 32 | 2 | attributes |
| 34 | 2 | version |
| 36 | 4 | creation date (seconds since 1904 or 1970, depends on the tool) |
| 40 | 4 | modification date |
| 44 | 4 | last backup date |
| 48 | 4 | modification number |
| 52 | 4 | app info offset |
| 56 | 4 | sort info offset |
| 60 | 4 | type: BOOK (TEXt for PalmDOC) |
| 64 | 4 | creator: MOBI (REAd for PalmDOC) |
| 68 | 4 | unique ID seed |
| 72 | 4 | next record list ID |
| 76 | 2 | number of records |
| 78 | 8 × n | record list: 4-byte offset, 1-byte attributes, 3-byte unique ID |
00000000 54 68 65 5F 42 6F 6F 6B 00 00 ... "The_Book" (name, 32 bytes)
0000003C 42 4F 4F 4B 4D 4F 42 49 "BOOKMOBI" at offset 60
0000004C 01 2C 300 records
Record 0: PalmDOC, MOBI and EXTH headers#
Record 0 starts with the 16-byte PalmDOC header:
| Offset | Size | Field |
|---|---|---|
| 0 | 2 | compression: 1 none, 2 PalmDOC (LZ77), 17480 HUFF/CDIC |
| 4 | 4 | uncompressed text length |
| 8 | 2 | number of text records |
| 10 | 2 | text record size, always 4096 |
| 12 | 2 | encryption: 0 none, 1 old Mobipocket, 2 Mobipocket / Kindle DRM |
The MOBI header follows at offset 16 of record 0. Important fields (offsets from the start of record 0):
| Offset | Field |
|---|---|
| 16 | MOBI identifier |
| 20 | header length |
| 24 | MOBI type: 2 Mobipocket book, 3 PalmDOC book, 232 or 248 (KindleGen output), 257 news and others |
| 28 | text encoding: 1252 (Windows Latin-1) or 65001 (UTF-8) |
| 36 | file version: 6 for MOBI 6, 8 for KF8 |
| 84 | offset of the full title in record 0 |
| 88 | length of the full title |
| 92 | locale (language) |
| 108 | first image record index |
| 128 | EXTH flags: bit 0x40 set means an EXTH header follows the MOBI header |
The EXTH header (EXTH, length, record count) holds metadata as tagged records:
| Tag | Meaning |
|---|---|
| 100 | author |
| 101 | publisher |
| 103 | description |
| 104 | ISBN |
| 105 | subject |
| 106 | publishing date |
| 113 | ASIN |
| 121 | KF8 boundary: record index where the KF8 part starts in a hybrid file |
| 201 | cover offset: cover image index, relative to the first image record |
| 202 | thumbnail offset |
| 501 | document type: EBOK (book), PDOC (personal document) |
| 503 | updated title |
| 524 | language |
Text records#
Each text record holds up to 4096 bytes of uncompressed text, compressed with PalmDOC LZ77 (a simple byte-oriented scheme) or HUFF/CDIC (Huffman with a dictionary, used by Amazon’s tools for store books). Records can end with trailing entries (multibyte character overlap, indexing data) described by the “extra data flags” field of the MOBI header; decoders must strip them before decompressing.
- MOBI 6 text is one long HTML document with Mobipocket tags (
<mbp:pagebreak/>),fileposattributes for links, andrecindexattributes for images. - KF8 text is HTML5 split into a skeleton and fragments (SKEL and FRAG index records) with an FDST record that separates HTML, CSS and SVG flows. Links and resources use
kindle:pos:fid:...andkindle:embed:XXXXURLs.
MOBI, AZW, AZW3 and hybrid files#
| File | Content |
|---|---|
.mobi (MOBI 6) |
old format, file version 6 |
.mobi (hybrid) |
KindleGen output: a MOBI 6 part, a BOUNDARY record, then a full KF8 part. Older Kindles read the first part, newer ones the second |
.azw3 |
KF8 only. The format Calibre creates for sideloading |
.azw |
Amazon store book: MOBI or KF8, usually with DRM |
.prc |
same as .mobi, from Palm-era Mobipocket tools |
.azw4 |
Print Replica: a PDF wrapped in the PalmDB container (the content record starts with %MOP); the pages are fixed |
.kfx, .azw (newer) |
KFX: Amazon’s current format, based on Amazon Ion. Not MOBI and not readable by MOBI tools |
DRM#
Books bought from Amazon (.azw, .azw3, KFX) are encrypted with a key tied to the Kindle device or app (encryption type 2 in the PalmDOC header). Only Amazon’s apps and devices open them. Readers and libraries that support MOBI, including SumatraPDF, Calibre and libmobi, open DRM-free files; libmobi can decrypt only with the device PID or serial number of the owner. Your own books created with Calibre or KindleGen have no DRM.
Converting#
- EPUB to AZW3 (for sideloading):
ebook-convert book.epub book.azw3with Calibre. - MOBI/AZW3 to EPUB:
ebook-convert book.azw3 book.epub, ormobitool -e book.mobifrom libmobi, or KindleUnpack, which recovers the original KF8 source. - For Kindle publishing: upload EPUB or DOCX to Kindle Direct Publishing, or use Amazon’s Kindle Previewer to check how a book looks on Kindle devices.
Specifications and documentation#
- MOBI format on the MobileRead wiki: the most complete description of the PDB, MOBI and EXTH headers
- KF8 on the MobileRead wiki: Kindle Format 8 structure
- PDB format on the MobileRead wiki: Palm Database container and PalmDOC compression
- Library of Congress: Mobipocket format description
- Calibre MOBI source code: reader and writer for MOBI 6 and KF8, the de facto reference
- Amazon: Kindle Publishing Guidelines: what Kindle supports in KF8
- Mobipocket on Wikipedia
Software that opens MOBI files#
| Software | Windows | macOS | Linux | Web | Can | Notes |
|---|---|---|---|---|---|---|
| SumatraPDF | ✓ | view | free, open source; .mobi, unencrypted .azw/.azw3/.prc; .azw4 opens the wrapped PDF | |||
| Calibre | ✓ | ✓ | ✓ | view, edit, convert | free, open source; converts MOBI/AZW3 to and from EPUB | |
| Kindle Previewer | ✓ | ✓ | view, convert | free from Amazon; previews books as they look on Kindle devices | ||
| KOReader | ✓ | view | free, open source; runs on Kindle, Kobo and PocketBook e-readers. Also on Android | |||
| Foliate | ✓ | view | free, open source; MOBI and AZW3 | |||
| FBReader | ✓ | ✓ | ✓ | view | free and paid versions. Also on Android and iOS | |
| Okular | ✓ | ✓ | view | free, open source document viewer | ||
| Moon+ Reader | view | free with paid Pro version. Also on Android | ||||
| KindleUnpack | ✓ | ✓ | ✓ | convert | free, open source; extracts HTML, images, EPUB from unencrypted files | |
| libmobi tools | ✓ | ✓ | ✓ | view, convert | mobitool, mobimeta: metadata, EPUB export, metadata editing |
Libraries#
Open-source libraries that read and write MOBI files. See all MOBI libraries for a comparison.
| C/C++ | libmobi, MuPDF |
|---|---|
| Go | mobi |
| Python | mobi, PyMuPDF |
| Rust | mobi |
| PHP | PHP eBook |