skillfed

EbookLib

Ebook library which can handle EPUB2/EPUB3 format

ebooklib v0.20 1.3M downloads/30d#4,077 on PyPI1,802
AGPL license GNU Affero General Public License Active released

What it is and what it does

EbookLib is a Python library for reading and writing EPUB2 and EPUB3 e-book files. It provides a straightforward API to parse EPUB archives, extract content (text, images, metadata), and programmatically construct new e-books from scratch. The library handles the underlying XML structure and ZIP packaging that EPUB files use, exposing a higher-level interface for chapters, metadata, covers, tables of contents, and styling.

The package depends on lxml for XML processing and six for Python 2/3 compatibility (though version 0.20 is the final release supporting Python 2.7). It is actively maintained, supports modern Python versions (3.9–3.13), and is used in production by several open-source projects including Booktype, Marker, and Telemeta. The API is designed to handle both simple operations and complex e-book structures.

Use it for:

  • Extract all images and text from an existing EPUB file for processing or conversion to another format.
  • Programmatically generate EPUB e-books from structured data (e.g., converting Markdown or HTML content into a publishable e-book).
  • Modify e-book metadata, add chapters, or rebuild the table of contents in an existing EPUB file.
  • Build e-book generation pipelines that produce EPUB output as part of a larger publishing workflow.
  • Parse and validate EPUB file structure for quality assurance or compliance checking.

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

EbookLib reads and writes EPUB2/EPUB3 files programmatically, allowing you to extract, modify, and create e-book content with support for metadata, covers, tables of contents, and multimedia.

Yes. EbookLib is a mature, actively maintained library with low install friction, no known vulnerabilities, and a clear use case for anyone working with EPUB files programmatically. The AGPL license is a significant consideration for proprietary projects, but poses no barrier for open-source work. Install it if you need to read, write, or manipulate EPUB files in Python.

Install

ebooklib on PyPI

pip

pip install ebooklib

uv

uv add ebooklib

poetry

poetry add ebooklib

Installing EbookLib

Before you install

Low install friction with only two runtime dependencies (lxml and six). The project is actively maintained with a recent commit on 2026-07-27 and 1802 repository stars. Version 0.20 is marked as the final release supporting Python 2.7; future versions will drop legacy support.

License in practice

Licensed under AGPL, which requires that any modifications or derivative works using this library must also be released under AGPL. This is a copyleft license with stronger obligations than permissive licenses—suitable for open-source projects but may conflict with proprietary software licensing strategies.

Quickstart

from ebooklib import epub

# Read an EPUB file
book = epub.read_epub('test.epub')
for image in book.get_items_of_type(ebooklib.ITEM_IMAGE):
    print(image.get_name())

# Write an EPUB file
book = epub.EpubBook()
book.set_title('My Book')
epub.write_epub('output.epub', book)

Verify before relying

  • Whether the library handles all EPUB3 optional features (e.g., fixed layouts, media overlays, embedded fonts).
  • Performance characteristics when processing large EPUB files or batch operations.
  • Compatibility with non-standard or corrupted EPUB files in the wild.

Package facts

License GNU Affero General Public License (agpl)
Python support supports the current Python release (>=2.7)
Install friction low — pure-Python wheel
Runtime dependencies 2 — lxml, six
Maintenance actively maintained — 292 days since the last release
Last repo commit
First released
Downloads 1,309,072/month — #4,077 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: ebooklib-0.20-py3-none-any.whl

Keywords: ebook, epub

Development Status :: 5 - Production/StableIntended Audience :: DevelopersLicense :: OSI Approved :: GNU Affero General Public License v3 or later (AGPLv3+)Operating System :: OS IndependentProgramming Language :: Python :: 2Programming Language :: Python :: 2.7Programming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.9Topic :: Software Development :: Libraries :: Python Modules

Tags

read write epub files pythonepub parser libraryebook format handlingepub2 epub3 supportprogrammatic ebook creationextract epub contentebook metadata management
epub-handlingebook-generation

More Python Modules packages