Bouxsaej neix caengz miz youq ndaw vah mwngz, ndigah yienh youq ndaw vah Yinghgoz.
Repair a Corrupt EPUB: Find What Broke Before Using a Tool
Diagnose a corrupt EPUB layer by layer with a free script, see which damage you can fix yourself, and learn when only a fresh download will work.

A corrupt EPUB is usually damaged in one specific layer: the file is not really an EPUB, the ZIP archive is cut off, the mimetype file is packed wrong, the pointer to the book's package file is broken, or a chapter inside is empty or malformed. Each layer has a different fix, and two of them have no fix at all except downloading the book again. So find the broken layer first. "Repair" tools that skip this step can hand you a file that opens but is missing a chapter.
This guide gives you a free triage script that names the broken layer, and shows what each kind of damage looks like. We built twelve test files, one valid book and eleven damaged copies, and recorded what the script reports for each and what BookTranslator's own EPUB importer does with it.
Check the layers in the order a reader opens them
An EPUB is a ZIP archive with a fixed structure, defined in the EPUB 3.3 specification. A reading app opens it in a fixed order, and a failure at one layer hides everything after it:
- File type. The file must start with a ZIP signature. A saved web page or a licence file with an
.epubname fails here. - ZIP archive. The index at the end of the archive must be present, and every entry must decompress to its declared size.
mimetype. The specification says themimetypefile must be the first file in the archive, contain exactlyapplication/epub+zip, and must not be compressed or encrypted.container.xml. The requiredMETA-INF/container.xmlnames the package document (the.opffile) through itsfull-pathattribute.- Package document. The
.opffile lists every file in the book (the manifest) and the reading order (the spine). - Chapters. Each chapter in the spine is an XHTML file that should be well-formed XML.
Run the script on your file:
python3 epub_triage.py book.epub
It needs only Python 3, reads the file without changing it, and prints one line per layer marked OK, WARN, or FAIL. Fix the first FAIL; later checks often depend on it. It does not replace EPUBCheck, the W3C conformance checker maintained by the DAISY Consortium, which checks far more but needs Java. The script answers a narrower question: why won't this file open, and is it worth fixing?
What each kind of damage looks like
We generated the test files with a fixture script on November 24, 2026, so you can rebuild them and check our results. The valid book has six short chapters and a table of contents. Each damaged copy changes one thing. The BookTranslator column shows what the EPUB importer in our current code did on the same day. The valid book produced 42 text segments, so a lower count means text was lost.
| Damage | What the triage script reports | BookTranslator importer |
|---|---|---|
Web page saved as .epub | FAIL file type: saved web page | Rejected: not a ZIP archive |
Adobe ACSM ticket renamed .epub | FAIL file type: ACSM licence file, not a book | Rejected: not a ZIP archive |
| Last quarter of the file missing (interrupted download) | FAIL zip: index at the end missing | Rebuilt the archive from the surviving entries: 36 of 42 segments, last chapter lost |
| One entry declares the wrong size | FAIL zip: entry cannot be read back intact | Re-packed the archive: all 42 segments |
mimetype compressed | WARN mimetype | Opened: all 42 segments |
container.xml points to a missing .opf | FAIL container, and names the .opf that is there | Opened using the only .opf: all 42 segments |
No .opf at all | FAIL container (points to a missing file), then FAIL package (no .opf anywhere) | Rejected: package document missing |
| Manifest lists a chapter that is not in the archive | FAIL manifest, names the file | Opened: 36 of 42 segments, that chapter absent |
One chapter has a bare & | WARN chapters: not well-formed | Opened: all chapters read |
| One chapter is a store's error text | WARN chapters: 1 of 6 not XHTML | Opened: 36 of 42 segments; the error text is kept untranslated |
| Three of six chapters empty or error text | FAIL chapters: 3 of 6 not XHTML | Rejected: "3 of 6 chapters are empty or not valid HTML" |
Two rows deserve a closer look, because the file opens but the book is incomplete. When the manifest lists a chapter that is not in the archive, a lenient program skips it. When the download stopped partway, a recovery tool rebuilds what arrived, and the end of the book is simply gone. In both cases the book "works", and you notice the gap only when you reach it. That is why the script reports these as FAIL even though some apps open the file: a file that opens is not the same as a complete book.
Damage you can fix yourself
Three kinds of damage are mechanical. The book's content is all there and only the packaging is wrong.
A compressed or misplaced mimetype. This usually happens when someone unzips an EPUB, edits it, and zips the folder again with an ordinary ZIP tool. Re-pack it with the mimetype file first and uncompressed. With the Info-ZIP zip command (included with macOS; on Linux, install the zip package), run this inside the unzipped folder:
zip -X0 ../fixed.epub mimetype
zip -rDX9 ../fixed.epub META-INF OEBPS
The first line stores mimetype uncompressed and without extra fields. The second adds everything else, compressed. Replace OEBPS with whatever folders your book contains besides META-INF. On our compressed-mimetype file, the re-packed copy passed every check.
A container.xml pointing to the wrong file. Open META-INF/container.xml in a text editor and change full-path to the .opf file the script found, for example OEBPS/package.opf. The path is relative to the root of the archive, not to META-INF. Then re-pack as above.
A bare & or another malformed character in a chapter. The script names the file and the line. Replace & with & (or < with <) at that position. If many chapters are malformed, calibre's editor has a Check book tool that finds malformed HTML, broken links, and OPF problems, and offers to auto-fix malformed HTML. Calibre's manual warns that auto-fixing "can sometimes have unexpected effects", and it saves a checkpoint you can revert to first.
Damage that means downloading again
The rest of the table is not packaging. Content is missing or was never there.
- Not a ZIP file. If the script says the file is a saved web page, the download link returned an error or a sign-in page instead of the book. Sign in and download again.
- An ACSM file. An
.acsmfile is a licence ticket that Adobe Digital Editions exchanges for the actual book, which is then usually DRM-protected. Renaming it does nothing. Read our guide on checking whether an ebook file is usable before you go further. - A truncated archive. Recovery tools can rebuild an archive from what arrived, and our importer does this too, but the missing part is missing. Download again and compare file sizes; the full download should be larger.
- A missing
.opfor missing chapters. Nothing in the file lists or contains the lost text. Re-download, or re-export from the original source. - Empty chapters or store error text. One store error page in place of a chapter is the signature of a bookstore download that failed partway. Re-download the book from the store.
If you have no other copy, an incomplete book can still be read. But treat any repaired file as incomplete until you have checked its table of contents against the chapters actually present.
Before you translate a repaired EPUB
A repaired EPUB that you plan to translate needs one more check, because translation multiplies a gap. A chapter missing from the source is missing from the translated book, and a chapter that was error text comes back as untranslated error text. Run the triage script again on the repaired file and confirm that every chapter is OK. Then open the book and page through the table of contents.
When the file is clean, upload it to the EPUB translator. The importer handles the cases in the BookTranslator column of the table above before it reads the book, and you see the price before you pay. It does not warn you when a chapter is missing, so the check above matters. If the upload is rejected, run the triage script on the file to see which layer failed. After translation, the EPUB translation QA checklist covers what to check in the output, and testing the translated book on real e-readers catches problems a single reading app hides.
What this test does not cover
The twelve files are small, generated books, not real bookstore downloads, and each has exactly one fault. Real damaged files can combine several. We did not test reading apps such as Apple Books, Kobo, or calibre's viewer against these files, so we make no claim about which apps open which damaged copies. The BookTranslator column reflects the importer code as of November 24, 2026, and may change. DRM-protected files are outside this guide: no repair applies to them.
Okuthunyelwe Okuhlobene





