Awesome Open Source
Awesome Open Source


C library for handling Mobipocket/Kindle (MOBI) ebook format documents.

For examples on how to use the library have a look at tools folder.


  • reading and parsing:
    • some older text Palmdoc formats (pdb),
    • Mobipocket files (prc, mobi),
    • newer MOBI files including KF8 format (azw, azw3),
    • Replica Print files (azw4)
  • recreating source files using indices
  • reconstructing references (links and embedded) in html files
  • reconstructing source structure that can be fed back to kindlegen
  • reconstructing dictionary markup (orth, infl tags)
  • writing back loaded documents
  • metadata editing
  • handling encrypted documents


  • improve writing
  • serialize rawml into raw records
  • process RESC records

Doxygen documentation:



[for git] $ ./
$ ./configure
$ make
[optionally] $ make test
$ sudo make install

Optionally provided Xcode and MSVC++ project files


  • single include file: #include <mobi.h>
  • linker flag: -lmobi
  • basic usage:
#include <mobi.h>

/* Initialize main MOBIData structure */
/* Must be deallocated with mobi_free() when not needed */
MOBIData *m = mobi_init();
if (m == NULL) { 
  return ERROR; 

/* Open file for reading */
FILE *file = fopen(fullpath, "rb");
if (file == NULL) {
  return ERROR;

/* Load file into MOBIData structure */
/* This structure will hold raw data/metadata from mobi document */
MOBI_RET mobi_ret = mobi_load_file(m, file);
if (mobi_ret != MOBI_SUCCESS) { 
  return ERROR;

/* Initialize MOBIRawml structure */
/* Must be deallocated with mobi_free_rawml() when not needed */
/* In the next step this structure will be filled with parsed data */
MOBIRawml *rawml = mobi_init_rawml(m);
if (rawml == NULL) {
  return ERROR;
/* Raw data from MOBIData will be converted to html, css, fonts, media resources */
/* Parsed data will be available in MOBIRawml structure */
mobi_ret = mobi_parse_rawml(rawml, m);
if (mobi_ret != MOBI_SUCCESS) {
  return ERROR;

/* Do something useful here */
/* ... */
/* For examples how to access data in MOBIRawml structure see mobitool.c */

/* Free MOBIRawml structure */

/* Free MOBIData structure */

return SUCCESS;
  • for examples of usage, see tools


  • compiler supporting C99
  • zlib (optional, configure --with-zlib=no to use included miniz.c instead)
  • libxml2 (optional, configure --with-libxml2=no to use internal xmlwriter)
  • tested with gcc (>=4.2.4), clang (llvm >=3.4), sun c (>=5.13), MSVC++ (2015)
  • builds on Linux, MacOS X, Windows (MSVC++, MinGW), Android, Solaris
  • tested architectures: x86, x86-64, arm, ppc
  • works cross-compiled on Kindle :)


  • Travis status
  • Coverity status

Projects using libmobi


  • LGPL, either version 3, or any later


  • The huffman decompression and KF8 parsing algorithms were learned by studying python source code of KindleUnpack.
  • Thanks to all contributors of Mobileread MOBI wiki

Get A Weekly Email With Trending Projects For These Topics
No Spam. Unsubscribe easily at any time.
c (14,542
library (1,276
ebook (104
kindle (26

Find Open Source By Browsing 7,000 Topics Across 59 Categories