Skip to main content

ebook-converter-lib

ebook-converter-lib is a Python library and command-line tool for converting ebooks between common formats. Licensed under GPL-3.0-or-later.

Install

python -m pip install ebook-converter-lib

Python 3.11 or newer is required. PDF input uses PDFium through pypdfium2 (installed automatically); no external tools are needed. Text, embedded images, the outline as table of contents, title, author and a first-page cover are taken from the PDF. Figures drawn with lines and curves (graphs, diagrams, tables) are detected and rendered as images in place.

Use as a library

from ebook_converter_lib import convert

result = convert("book.docx", "book.epub")
if not result["success"]:
    raise RuntimeError(result["message"])

convert() returns a dictionary with success and message keys. Use check_deps_str() to verify that conversion dependencies can load in an embedded Python runtime.

Options

Extra arguments use the command-line option format:

convert("book.epub", "book.mobi", "--base-font-size", "12")
  • --remove-text: one regular expression per line, every match is deleted. Escape special characters for literal text, e.g. C\+\+.
  • Unknown options, stray values and invalid regular expressions fail the conversion.

Ebook metadata

from ebook_converter_lib import read_metadata, update_metadata

book = read_metadata("book.epub")
result = update_metadata("book.epub", "updated.epub", title="New title")
result = update_metadata("book.azw3", "updated.azw3", authors=["New Author"])

Supports EPUB 2/3 (default rendition only) and DRM-free AZW3/MOBI, including hybrid MOBI files containing both legacy MOBI and KF8. No conversion; input and output extensions must match. Check success and message. book["metadata"] contains title, authors (list), publisher, comments; missing fields are ""/[], and failures return None. Updates accept these fields as keywords: omitted/None preserves, empty publisher/comments clears. Title and author names must be non-blank; the author list must be non-empty. The source stays untouched; a different output is replaced only on success. Book content and images are preserved; malformed XML or Kindle record structures fail, and cover changes are unsupported. Kindle updates retain unrelated EXTH records and update both metadata headers in hybrid files. Legacy Windows-1252 books reject text that cannot be represented in their original encoding.

Command line

ebook-converter book.docx book.epub

Supported formats

Input: azw, azw3, docm, docx, epub, fb2, fbz, htm, html, htmlz, lrf, markdown, md, mobi, odt, opf, pdb, pdf, pobi, prc, rtf, shtm, shtml, text, textile, txt, txtz, updb, xhtm, xhtml.

Output: azw3, docx, epub, fb2, html, htmlz, lrf, mobi, oeb, txt, txtz.

The output format is chosen from the output file extension.

Development

uv sync --group dev
uv run pytest

Credits

Metadata

Release files for ebook-converter-lib 1.6.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 ebook-converter-lib 1.6.1
File Size Uploaded Provenance Actions
ebook_converter_lib-1.6.1.tar.gz 1.5 MB With provenance Details for ebook_converter_lib-1.6.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for ebook-converter-lib 1.6.1
File Interpreter ABI Platform Actions
ebook_converter_lib-1.6.1-py3-none-any.whl Python 3 none any Details for ebook_converter_lib-1.6.1-py3-none-any.whl

Total release size: 3.2 MB

Release files / ebook_converter_lib-1.6.1.tar.gz

Download URL ebook_converter_lib-1.6.1.tar.gz
Size 1.5 MB
Tags Source
SHA-256 checksum
How to use checksums
4a4a155eff6f0faade78eda1632632820993880326bdd5dcf99d1823116cc23e
BLAKE2b-256 checksum
How to use checksums
4f82aac9033c7066f78551477db98642d85377925cf635bb1dc2dc4317088ad7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 2, 2026.

Transparency log

Release files / ebook_converter_lib-1.6.1-py3-none-any.whl

Download URL ebook_converter_lib-1.6.1-py3-none-any.whl
Size 1.7 MB
Tags Python 3
SHA-256 checksum
How to use checksums
db87d9ea50f53ebd5e41fee1ad4752e87f4e742a93fe093417ef96b53d8de444
BLAKE2b-256 checksum
How to use checksums
95faff2eef90bd2fe6ff270e9dbdbb7e4efc318dd4eadac2d3a4a2a502bb6219
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 2, 2026.

Transparency log

Security for ebook-converter-lib 1.6.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for ebook_converter_lib-1.6.1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 2, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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