When plain text is the right target
Plain text has no layout, no fonts and no images, and that is why people ask for it. It can be searched with any tool, read aloud by a text-to-speech program, compared with another edition using a diff tool, pasted into a translation memory, or fed to a word counter. If you want those uses, TXT is better than any rich format.
Steps with the PDFSwift tool
- Open EPUB to TXT.
- Choose the EPUB or drag it onto the page.
- Press Convert to TXT.
- Look at the preview and the chapter and word counts.
- Press Download TXT.
The conversion happens in your browser. The book is not uploaded, and the page does not need to talk to a server to produce the file.
What the text file contains
- The book’s title and author at the top.
- Every section in the order the book’s spine lists them, separated by three blank lines.
- Headings on their own lines, paragraphs separated by a blank line.
- List items with a dash or number, block quotations marked with
>, table rows with cells separated by a vertical bar. - Images as
[Image: alt text]when the book gave alt text.
HTML entities are decoded, so —, and numeric references like — come out as the real characters.
Encoding, Arabic and other scripts
The file is UTF-8. That covers every script, including Arabic, Hebrew, Cyrillic, Greek, Devanagari and CJK, without conversion or transliteration. If a text editor shows nonsense, it is probably reading the file as a legacy code page. Choose UTF-8 explicitly when opening it. Right-to-left text is stored in logical order, as it should be; the direction is applied when it is displayed.
What gets lost
- Bold, italics and font changes.
- Page layout, columns and images themselves.
- Link targets and footnote jump links (footnote text stays where the book placed it).
If you need structure such as heading levels and emphasis, convert to Markdown instead. If you only need chapters in separate files, or the quotations, use the text extractor.
Checking the result
- Compare the number of sections with the table of contents of the book.
- Search the text file for a phrase you know is in the last chapter.
- Look at one chapter with a list and one with a table to see how they were written.
If chapters are missing, the book’s reading order may not list them. The validator will show it, and the repair tool can re-link chapters that the table of contents still points to.
A note on DRM
Books from stores may be encrypted. The converter reads the file exactly as stored; for an encrypted book the result is unreadable text, and these tools do not remove protection. Use books you are allowed to convert.
Cleaning the text for common uses
The output is intentionally plain, but some uses want a little more tidying. Here are the changes that come up most often, with commands for a Unix-style shell, available on macOS, Linux and Windows with WSL or Git Bash.
| You want | Command or step |
|---|---|
| Word count | wc -w book.txt |
| Search with context | grep -n -i -C 2 "phrase" book.txt |
| Remove line breaks inside paragraphs for pasting | Join lines that are not followed by a blank line; most editors have a “join lines” command. |
| Compare two editions | diff -u edition1.txt edition2.txt |
| Split into chapters | Use the text extractor to get one file per chapter instead of splitting by hand. |
| Strip the first lines (title, author) | tail -n +4 book.txt > body.txt |
Using the file with text-to-speech
Most text-to-speech tools read everything they are given, including the copyright page and the contents list. Delete those parts from the beginning of the text file first. If the voice mispronounces a recurring name, find and replace it with a phonetic spelling in the text copy, which does not affect your EPUB.
Language learning
Plain text imports easily into vocabulary and flashcard tools, and many reading-comprehension tools accept it. Because the file is UTF-8 and unaltered, accented letters and non-Latin scripts remain intact. For right-to-left languages, check that the program you import into handles bidirectional text; the file itself is stored in logical order, which is the correct form.
What the converter will not do
- It does not hyphenate or re-wrap text to a column width.
- It does not guess where footnotes belong; they appear where the book put them.
- It does not convert scanned books made of page images, since there is no text to extract.