← toolkit.bot

How to Repair a Broken or Corrupted EPUB File

EPUB files can become unreadable after a bad download, failed conversion, or accidental edit. Here's how to diagnose what's wrong and fix most common EPUB errors.

Symptoms of a Broken EPUB

Step 1: Run EPUBCheck to Identify the Problem

Before attempting repairs, diagnose the specific errors:

java -jar epubcheck.jar book.epub

Read the error output carefully. EPUBCheck identifies exactly which files have problems and what type of error. Common categories:

Step 2: Open the EPUB as a ZIP

EPUB files are ZIP archives. Rename the file from .epub to .zip and extract it to inspect the internals:

# On macOS/Linux
cp book.epub book.zip
unzip book.zip -d book-extracted/

# On Windows
Rename-Item book.epub book.zip
Expand-Archive book.zip -DestinationPath book-extracted

The extracted folder contains: META-INF/container.xml, an OPF file (usually in OEBPS/ or content.opf), HTML chapter files, CSS, and images.

Fix 1: Missing or Mislinked Files (RSC-007)

The most common EPUB error: a file referenced in the OPF manifest doesn't exist (wrong filename, case mismatch, or file was deleted).

  1. Open the OPF file in a text editor. Find the <manifest> section.
  2. Check each <item href="..."> — the path must exactly match the actual filename (case-sensitive on Linux/macOS).
  3. Add any missing files back to the EPUB folder, or remove the manifest entry if the file is truly absent.
  4. Repack: zip the folder back into an EPUB (the mimetype file must be first and uncompressed).
# Repack EPUB correctly (mimetype must be first, stored uncompressed)
cd book-extracted/
zip -X ../book-fixed.epub mimetype
zip -rg ../book-fixed.epub META-INF OEBPS

Fix 2: Missing or Empty TOC (NAV-003)

If the EPUB has no nav.xhtml or the NAV document is empty:

  1. Open Sigil or Calibre's Edit Book.
  2. Go to Tools → Table of Contents → Generate Table of Contents.
  3. This creates or rebuilds the NAV document from heading tags in the chapter files.
  4. Save the EPUB.

Fix 3: Malformed OPF (Missing Required Metadata)

KDP and EPUBCheck require these fields in the OPF <metadata>:

<dc:title>Book Title</dc:title>
<dc:language>en</dc:language>
<dc:identifier id="uid">urn:uuid:your-uuid-here</dc:identifier>

Open the OPF file, add any missing elements, and save. Use Calibre's metadata editor (select book → E) as a GUI alternative.

Fix 4: Corrupted ZIP Structure

If the EPUB can't be opened as a ZIP (completely corrupted), try:

# Test ZIP integrity
unzip -t book.epub

# Attempt ZIP repair
zip -F book.epub --out book-repaired.epub

If the ZIP is damaged beyond repair, check if you have a backup or re-download the file from the original source.

Fix 5: Use Calibre to Reconvert

For EPUBs that won't open in readers but can still be parsed, Calibre's reconvert pipeline often repairs structural problems automatically:

  1. Add the broken EPUB to Calibre.
  2. Right-click → Convert books → Convert individually.
  3. Set input AND output format to EPUB.
  4. Click OK. Calibre parses and re-exports the EPUB, fixing many structural errors.

Online EPUB Repair Tools

Converting a PDF to a clean EPUB from scratch? toolkit.bot generates EPUBCheck-valid output.

Convert PDF to EPUB →

Related guides