Blog · EPUB

How to Extract Text From an EPUB

Decide what shape you need

“Extract the text” can mean four different things, and choosing the right one saves a lot of cleaning. The EPUB Text Extractor offers all four on the same loaded book.

You wantModeOutput
Everything, to copy or searchFull textOne UTF-8 text file
One chapter at a timeOne text file per chapterZIP with numbered files
Memorable linesQuotationsList of passages inside quotation marks
Everything about a word or a namePassages containing…List with context

Steps

  1. Choose the EPUB.
  2. Pick the mode; for passage search, type the word or phrase.
  3. Press Extract.
  4. Copy from the page or press the download button.

Everything runs in your browser. The book is not uploaded.

How each mode works

Full text walks the book’s reading order and writes headings, paragraphs, list items and quotations on separate lines. Chapters writes one file per reading-order item and names it with the table-of-contents entry when there is one. Quotations matches text between curly, straight or guillemet quotation marks that is 20 to 600 characters long; that excludes short exclamations and runaway matches. Passage search finds every occurrence ignoring capitalisation and shows around 160 characters on either side.

Working with the result

Limits you should know

If you want structure kept, such as headings and emphasis, convert to Markdown. For a single clean file with no choices, EPUB to TXT is quicker.

A research workflow

Suppose you are writing a paper that discusses one novel and need accurate quotations with locations. A workable routine with the extractor is:

  1. Extract one text file per chapter. Keep the ZIP with your notes; the file names carry the chapter order and title.
  2. Use passage search for each term or character name you are tracking. Copy the passages you want into your notes together with the chapter file name.
  3. Use quotations to find lines the author set in quotation marks, which is a fast way to list speech for dialogue analysis.
  4. Check each quotation against the book in the reader before it goes into a manuscript, because extraction can join or split text around footnotes.

Cleaning typical artefacts

ArtefactCauseRemedy
Words split with a hyphen at line endsThe book was converted from a print layoutSearch for a hyphen followed by a line break and join the parts.
Footnote numbers glued to wordsSuperscript numbers become plain digits in textRemove digits that directly follow a word with a regular expression.
Running headers repeatedPrint page headers preserved in the fileSearch for the repeated header line and delete it.
Missing paragraph breaksThe book uses line breaks instead of paragraphsAdd blank lines at sentence ends if you need paragraphs.

What the passages output looks like

Each result shows the match with about 160 characters on either side, trimmed to whole spaces and marked with an ellipsis where the passage was cut. It is a reading aid: for a citation, go to the book and check the surrounding paragraph.

Respecting rights

Extracting text for your own study, accessibility or analysis is a different matter from republishing it. Check the copyright and licence of the book before sharing extracted text or large quotations.