Skip to main content

mobi - library for unpacking unencrypted mobi files

Version Downloads

A fork of KindleUnpack which removes the GUI part and makes it available as a python library via PyPi for easy unpacking of mobi files.

Installation

# Using uv (recommended)
uv add mobi

# Using pip
pip install mobi

Usage

As library

import mobi
import tempfile
import shutil

# Extract the mobi file
tempdir, filepath = mobi.extract("mybook.mobi")

# Use the extracted file
with open(filepath, 'r') as f:
    content = f.read()
    # Process the content...

# Clean up the temporary directory
shutil.rmtree(tempdir)

tempdir is the path where the mobi is unpacked
filepath is the path to either an epub, html or pdf file depending on the mobi type

⚠️ Important: You are responsible for deleting the temporary directory after use to avoid filling up disk space.

From the command line

The installer also creates a console script entrypoint that wraps the original KindleUnpack

$ mobiunpack
KindleUnpack v0.82
   Based on initial mobipocket version Copyright © 2009 Charles M. Hannum <root@ihack.net>
   Extensive Extensions and Improvements Copyright © 2009-2014
       by:  P. Durrant, K. Hendricks, S. Siebert, fandrieu, DiapDealer, nickredding, tkeo.
   This program is free software: you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation, version 3.

Description:
  Unpacks an unencrypted Kindle/MobiPocket ebook to html and images
  or an unencrypted Kindle/Print Replica ebook to PDF and images
  into the specified output folder.
Usage:
  mobiunpack -r -s -p apnxfile -d -h --epub_version= infile [outdir]
Options:
    -h                 print this help message
    -i                 use HD Images, if present, to overwrite reduced resolution images
    -s                 split combination mobis into mobi7 and mobi8 ebooks
    -p APNXFILE        path to an .apnx file associated with the azw3 input (optional)
    --epub_version=    specify epub version to unpack to: 2, 3, A (for automatic) or
                         F (force to fit to epub2 definitions), default is 2
    -d                 dump headers and other info to output and extra files
    -r                 write raw data to the output folder

[0.4.1] - 2025-09-14

  • Fix DeprecationWarning for deprecated datetime.utcnow() by using timezone-aware alternative
  • Fix DeprecationWarning for count being passed as positional argument in re.sub()
  • Fix DeprecationWarning by using array.array.tobytes() instead of deprecated tostring() method
  • Exclude development files from source distribution to reduce package size

[0.4.0] - 2025-08-26

  • BREAKING: Drop Python 2 support, modernize codebase
  • BREAKING: Bump minimum Python version to 3.9
  • Replace deprecated imghdr module with standard-imghdr for Python 3.11+ compatibility
  • Update loguru dependency to v0.7+ for Python 3.11 support
  • Migrate build system from Poetry to uv/hatchling
  • Add Python 3.10 and 3.11 to CI testing
  • Add pre-commit hooks for code quality
  • Code formatting updates with latest black

[0.3.3] - 2022-03-03

  • Add GitHub build workfow
  • Updated dependencies
  • Rmoved python 3.6 support (EOL)

[0.3.2] - 2021-10-14

  • Update dependencies

[0.3.1] - 2020-06-27

  • Fix pypi link
  • Update dependencies

[0.3.0] - 2020-03-02

  • Add support for mobi7 only files
  • Add experimental support for mobi print replica files
  • Add support for file-like objects

[0.2.0] - 2020-03-02

  • Minimal working 'extract' function and 'mobiunpack' console wrapper
  • Replace most print calls with logging

[0.1.0] - 2020-03-02

  • Empty package registered on pypi

License

GPL-3.0-only

All credits for the hard work go to https://github.com/kevinhendricks/KindleUnpack

Release files for mobi 0.4.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mobi 0.4.1
File Size Uploaded
mobi-0.4.1.tar.gz 106.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for mobi 0.4.1
File Interpreter ABI Platform
mobi-0.4.1-py3-none-any.whl Python 3 none any Details

Total release size: 206.3 kB

Release files / mobi-0.4.1.tar.gz

Download URL mobi-0.4.1.tar.gz
Size 106.4 kB
Tags Source
SHA-256 checksum
How to use checksums
9b814f42cd3750d22377e8095d84974943b94dd8081a90a1c403c64c3602bd26
BLAKE2b-256 checksum
How to use checksums
7ffcefbab42351ebdd594e23f069934bff882f1c15129f61cbff13d1990243b5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.8.17

Release files / mobi-0.4.1-py3-none-any.whl

Download URL mobi-0.4.1-py3-none-any.whl
Size 99.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5490ea1d8e62c4d94352b6ba8eb117b9f9e5df2a1e8b38687c11d1f390cf86e5
BLAKE2b-256 checksum
How to use checksums
e102cacca68175f8fbdb9d4cf81028e924e5d1d0c29c509fe6721d331ed61921
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.8.17

Release history Release notifications | RSS feed

This release

0.4.1 This release

2 release files

0.4.0

2 release files

0.3.3

1 release file

0.3.2

1 release file

0.3.1

2 release files

0.3.0

2 release files

0.2.0

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page