Zum Inhalt springen

epub-utils: A Python library and CLI tool for inspecting EPUB files

I’ve been working on epub-utils, a Python library and command-line tool that makes it quick and easy to inspect EPUB files from the terminal or in your Python scripts.

The problem I was trying to solve

I frequently work with EPUB files and found myself constantly needing to peek inside them to check metadata, validate structure, or debug formatting issues. The existing tools were either too heavy-weight (full EPUB readers/editors) or required extracting the ZIP manually and parsing XML by hand.

I wanted something as simple as file or head but for EPUB files – just run a command and immediately see what’s inside.

Quick examples

Install from PyPI:

pip install epub-utils 

Then inspect any EPUB file:

# See the container.xml structure epub-utils book.epub container # Extract metadata from package.opf epub-utils book.epub package # View table of contents epub-utils book.epub toc 

By default you get syntax-highlighted XML output, but you can get plain text with --format text if you’re piping to other tools.

As a Python library

A Document interface is available in the Python library

from epub_utils import Document doc = Document("book.epub") # See the container.xml structure doc.container.to_str() # Extract metadata from package.opf doc.package.to_str() # View table of contents doc.toc.to_str() 

This makes it trivial to batch-process EPUB collections, validate metadata, or build other tools on top of it.

Why I built this

I work with digital publishing workflows and kept running into the same friction: I’d have a folder of EPUB files and need to quickly check their metadata or structure. Opening each one in a full reader was too slow, and manually extracting the ZIP was tedious.

epub-utils scratches that itch – it’s designed for the command line first, with the Python API as a nice bonus for automation.

What’s next

I’m considering adding features like:

  • Metadata validation against EPUB specs
  • Bulk operations (process entire directories)
  • Export to CSV/JSON for analysis

If you work with EPUB files, I’d love to hear what features would be most useful to you!

Links:

submitted by /u/makeascript
[link] [comments]

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert