A lightweight, zero-dependency Python script to convert EPUB files into the legacy MOBI (MOBI6) format.
This tool is designed for simplicity and longevity. It does not rely on kindlegen, calibre, or heavy external libraries. It writes the binary headers manually using the Python standard library, making it ideal for archival purposes or supporting also older Kindle devices.
- Zero Dependencies: Runs on any machine with Python 3.7+. No
pip installrequired. - Legacy Support: Forces
CP1252encoding and simplified HTML to ensure maximum compatibility with old E-Ink devices. - Auto-Deploy: Automatically detects a connected Kindle via USB and copies the file to the
documentsfolder. - Smart Sanitization: Strips complex CSS/JS but preserves structure (chapters, paragraphs, bold/italic, lists) for a distraction-free reading experience.
- Download the script:
wget https://raw.githubusercontent.com/hyle/epub2mobi/main/epub2mobi.py
- Run the conversion:
python3 epub2mobi.py my_book.epub
Creates my_book.mobi in the same directory.
3. Convert & Copy to Kindle:
python3 epub2mobi.py my_book.epub --deploy
- Text & Structure Only: Images are intentionally stripped to keep the file size low and the code simple.
- MOBI6 Format: This generates the older "MobiPocket" format, not the newer AZW3/KF8 format. It does not support embedded fonts or advanced CSS.
MIT License. Feel free to modify and publish.