EPUB to TXT — the spine decides the order, unreferenced files are skipped
An ebook is a ZIP archive of small HTML documents, and the filenames inside it often do not match the order a reader sees. The conversion walks the spine — the manifest that declares reading order — and writes the text in that sequence. A file that exists in the archive but is not referenced by the spine never appears in the output.
Page layout, fonts, margins, headers, footers and page breaks are not reproduced: the text stream is reflowed, not re-laid-out.
Processed on your device. Files aren’t sent anywhere.
The spine is the reading order
EPUB separates two things: the files in the archive and the order in which they are read.
- The archive holds chapter documents, styles, images and metadata.
- The spine lists which documents are part of the reading flow, and in what sequence.
- The extraction follows that list, so output order matches the order a reader experiences.
- Documents not listed in the spine are skipped, even when they are valid files inside the archive.
- Only text is extracted: images, page layout and fonts are dropped.
Questions about spine-based extraction
Why is a chapter missing from the text?
Does the output follow the filenames?
Are the ebook's images kept?
How big an ebook can be converted?
File order versus output order
Consider an ebook whose chapter files were named during production in a different sequence from the reading order.
| File in the archive | Spine position | Position in the TXT output |
|---|---|---|
| 03.xhtml | first in the spine | first text in the output |
| 01.xhtml | second in the spine | second text in the output |
| 02.xhtml | third in the spine | third text in the output |
| appendix.xhtml | not in the spine | absent from the output |
| cover.xhtml | not in the spine | absent from the output |
Chapters the spine does not reference
A missing chapter is usually not a failure. Covers, title pages and production leftovers commonly live in the archive without being part of the spine, so they are correctly ignored.
If a chapter you expected is absent, that is worth checking rather than assuming the reader broke: only spine-listed documents are read. Convert the same file toward HTML and compare, or inspect the spine in the archive to see whether the chapter is listed.
Checking the extracted text
Because headings, lists and tables become plain lines, verification is about sequence and coverage.
- Convert the .epub and download the .txt.
- Read the first lines and confirm they match the chapter the ebook opens with.
- Search for a phrase from the last spine-listed chapter to confirm the walk reached the end.
- Look for the chapter you expected but did not find, then check whether the spine lists it.
- Compare the character count with the 400000-character output cap.
- If structure matters, convert the same ebook toward sanitized HTML.
The spine is a promise about reading order; the archive listing is only a directory.
Why filenames mislead when you extract an ebook