Kindle Format 8 keeps the container of the older MOBI format: a Palm OS database (PDB) of numbered records. Amazon has never published the format; this page follows the readers in calibre and KindleUnpack and the MobileRead Wiki. All numbers are big-endian.
PDB header
The file starts with the same 78-byte database header as a MOBI file. The fields that matter to a KF8 reader:
| Offset | Size | Type | Name | Description |
|---|---|---|---|---|
0 | 32 | char[32] | name | A short name for the book, ended by a zero byte; the real title is in record 0. |
32 | 2 | UInt16 | attributes | Palm OS flags; 0 in books. |
34 | 2 | UInt16 | version | 0. |
36 | 12 | 3 × UInt32 | dates | Creation, modification and backup times, in seconds from 1904 (top bit set) or from 1970 (top bit clear). |
48 | 12 | 3 × UInt32 | Modification number, app info and sort info offsets: all 0. | |
60 | 4 | char[4] | type | BOOK. |
64 | 4 | char[4] | creator | MOBI. |
68 | 8 | 2 × UInt32 | Unique ID seed and next record list: not used. | |
76 | 2 | UInt16 | numRecords | The number of records. |
78 | 8 × N | entries | record list | Per record: a UInt32 file offset, a UInt8 of attributes and a UInt24 ID. Two zero bytes follow the list. |
Every field is described on the MOBI PDB header page. The type and creator are the same for MOBI and KF8, so a reader tells them apart from the version in the MOBI header of record 0 and from EXTH 121.
Stand-alone and joint files
| Kind | Record 0 MOBI version | How to recognise it | Usual name |
|---|---|---|---|
| Stand-alone KF8 | 8 | The MOBI header’s version is 8 and its skeleton index is set. | .azw3 |
| Joint MOBI and KF8 | 6 | EXTH 121 in record 0 gives a record number, and the record before it is the 8 bytes BOUNDARY. | .mobi or .azw, as made by KindleGen 2 and later |
| MOBI only | 6 or lower | No EXTH 121, or no BOUNDARY record. | .mobi, .prc |
KindleGen 2 made joint files so that one file could serve older Kindles, which read the MOBI part, and newer ones, which read the KF8 part. Splitting the KF8 part out of a joint file, as KindleUnpack and calibre can, gives a stand-alone KF8 file.
Joint file layout
- Record 0: the version 6 headers, with EXTH 121 holding the record number of the KF8 record 0.
- The MOBI part: text, indexes and images, as in a MOBI file.
- The
BOUNDARYrecord: the 8 ASCII bytesBOUNDARY. - The KF8 record 0, with the version 8 headers.
- The KF8 part: text, indexes, FDST, FLIS, FCIS, DATP, and so on.
- The end-of-file record,
E9 8E 0D 0A.
Every record number in the KF8 headers and indexes counts from the KF8 record 0, not from the start of the file: a reader adds the number of the KF8 record 0 to each.
A stand-alone AZW3 is the KF8 part on its own, with its record 0 as record 0 of the file.
Order of the records
A stand-alone KF8 file made by calibre or KindleUnpack has its records in this order:
| Records | Content | Found from |
|---|---|---|
| 0 | PalmDOC header, MOBI header, EXTH, title | always first |
| 1 to n | Text records | PalmDOC header’s record count |
| … | Optional zero-length or padding record | |
| … | Fragment, skeleton, NCX and guide indexes, each with its CNCX records | MOBI header 0xF8, 0xFC, 0xF4, 0x104 |
| … | Resources: images, FONT, RESC, placeholders | MOBI header 0x6C |
| … | FDST | MOBI header 0xC0 |
| … | FLIS, FCIS, DATP | MOBI header 0xD0, 0xC8, 0x100 |
| last | End of file, E9 8E 0D 0A |
The order is a convention; readers should follow the numbers in the MOBI header. The
FLIS, FCIS and end-of-file records have the same content as in
MOBI files: see MOBI index and other
records.