All formats

MOBI (Mobipocket and Kindle e-books)

Full nameMobipocket e-book; Amazon Kindle formats AZW, AZW3 (KF8)
Extensions.mobi, .azw, .azw3, .prc; related: .azw4 (Print Replica), .pdb (PalmDOC)
MIME typeapplication/x-mobipocket-ebook; application/vnd.amazon.ebook (AZW), application/vnd.amazon.mobi8-ebook (AZW3)
Typee-book, reflowable HTML text in a Palm Database container
Starts with32-byte book name, then BOOKMOBI at offset 60 (TEXtREAd for PalmDOC)
Specificationno official public specification; documented by the MobileRead wiki
Maintained byAmazon (proprietary)
Licenseproprietary, 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#

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, 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#

Specifications and documentation#

Software that opens MOBI files#

SoftwareWindowsmacOSLinuxWebCanNotes
SumatraPDF✓viewfree, open source; .mobi, unencrypted .azw/.azw3/.prc; .azw4 opens the wrapped PDF
Calibre✓✓✓view, edit, convertfree, open source; converts MOBI/AZW3 to and from EPUB
Kindle Previewer✓✓view, convertfree from Amazon; previews books as they look on Kindle devices
KOReader✓viewfree, open source; runs on Kindle, Kobo and PocketBook e-readers. Also on Android
Foliate✓viewfree, open source; MOBI and AZW3
FBReader✓✓✓viewfree and paid versions. Also on Android and iOS
Okular✓✓viewfree, open source document viewer
Moon+ Readerviewfree with paid Pro version. Also on Android
KindleUnpack✓✓✓convertfree, open source; extracts HTML, images, EPUB from unencrypted files
libmobi tools✓✓✓view, convertmobitool, 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
Gomobi
Pythonmobi, PyMuPDF
Rustmobi
PHPPHP eBook