Convert2EPUB
Menu
← Blog

How to convert a TXT file to EPUB with chapters

Last updated: 13 November 2026

To convert a TXT file to EPUB with working chapters, make sure each chapter title sits on its own line in a consistent pattern, then run the file through a converter that builds a table of contents from those headings. A TXT file has no formatting, so chapters only appear if the converter can recognise your headings or you mark them up yourself.

This guide covers how to prepare the file, which conversion route fits which kind of book, and how to check that the result works on an e-reader.

Why does a TXT file lose its chapters when converted to EPUB?

A TXT file stores only characters, with no styles, headings or page structure. A converter therefore has to guess where chapters begin, and it fails when your headings don't look like headings.

An EPUB is a packaged set of web-style pages. Its table of contents is a separate navigation list that points at those pages. To build it, a converter needs to know that "Chapter 3" is a title, not a sentence. In a TXT file, nothing says so except how the line looks.

Three things commonly go wrong:

  • Hard line breaks. Many older plain-text books are wrapped at about 60 to 80 characters per line. If the converter treats each break as a paragraph break, the book reads as ragged fragments on a small screen.
  • Inconsistent headings. "CHAPTER ONE", "Chapter 2" and "3." in the same file mean no single detection rule catches all of them.
  • Wrong character encoding. Curly quotes, accents and dashes turn into strange symbols if the file isn't read as UTF-8.

How do I prepare a TXT file before converting it?

Prepare the file by fixing line breaks, standardising chapter headings and saving as UTF-8. Ten minutes in a text editor usually decides whether the conversion works.

  • Save as UTF-8. Every modern editor offers this under "Save as" or "Encoding". Do it first, before you edit anything else.
  • Look at the line breaks. Open the file with word wrap turned off. If every line stops at the same width, the text is hard-wrapped. If each paragraph is one long line, you're fine.
  • Separate paragraphs with a blank line. This is the clearest signal that a paragraph ended. A blank line works for most converters.
  • Make every chapter heading look the same. Pick one pattern, such as Chapter 1: The Arrival, and apply it to every chapter. Put a blank line above and below each heading.
  • Search for stray page furniture. Plain-text copies of printed books often contain page numbers, running headers like "THE GREAT VOYAGE – 47", or licence boilerplate in the middle of the text. Delete them. Our guide on removing watermarks and page numbers when converting to an ebook covers the same problem for PDFs.
  • Put the title and author at the top. You'll usually enter them again as metadata, but having them in the file avoids "Untitled" on your library shelf.

Fixing hard-wrapped lines

If the file is hard-wrapped, join the lines back into paragraphs before converting. A common approach is a regular-expression search in an editor that supports them (VS Code, Notepad++ and Sublime Text do). Replace a single newline that is not followed by another newline with a space. Keep the double newlines between paragraphs.

Check a few pages afterward. Poetry, dialogue lists and addresses may need their line breaks restored by hand.

Marking chapters explicitly with Markdown

The most reliable way to get chapters is to mark them yourself. Put # before each chapter title:

# Chapter 1: The Arrival

          The ship came into harbour just before dawn...

This is Markdown, and it's still readable as plain text. Converters that understand Markdown, including Pandoc, treat these lines as chapter headings. If you'd like to go further with this approach, see our guide to converting Markdown to EPUB.

What are the ways to convert TXT to EPUB with chapters?

You can use a no-install online converter, Calibre, or Pandoc. An online converter is quickest for a single book. Calibre suits large libraries and fine control, and Pandoc suits writers who want repeatable builds from a command line.

MethodInstall neededChapter handlingBest for
Online converter (such as Convert2EPUB)NoAutomatic detection, then you check the resultA one-off book, or a quick conversion from any device
CalibreYes (desktop app)Pattern-based detection you can adjust, plus Markdown or Textile input optionsMany files, or books with unusual heading styles
PandocYes (command line)Splits chapters at the headings you mark with #Writers who already work in Markdown

Option 1: An online converter

On our TXT to EPUB page you drop the file in, set the title and author, and download the EPUB. Convert2EPUB accepts TXT files up to 100 MB. Its Standard conversion is listed as free for text files. Uploaded files are deleted automatically, according to the site.

Steps:

  • Prepare the file as described above.
  • Upload it and choose EPUB as the output.
  • Leave the mode on Auto, or choose Reflowable for a normal book. See reflowable vs fixed layout EPUB if you're unsure. Plain text should almost always be reflowable.
  • Pick the target device closest to yours, such as a 6-inch e-ink reader or a tablet.
  • Enter the title and author, convert, and download.

Then check the table of contents (covered below). If chapters are missing, fix the headings in the TXT file and convert again, which is quicker than editing the EPUB.

Option 2: Calibre

Calibre is a free desktop program for managing ebooks. When you convert a TXT file, its conversion options let you tell it how the text is formatted. These include whether it's plain text, Markdown or Textile, and how paragraphs are separated. It also lets you set the pattern used to detect chapters.

If your headings are irregular, Calibre's chapter detection is the main reason to choose it. The setting accepts a rule describing what a chapter heading looks like. The Calibre user manual documents the conversion options. The interface is dense, so expect some trial and error.

Option 3: Pandoc

Pandoc is a command-line document converter. It reads Markdown natively, so a TXT file with # headings converts directly:

pandoc book.txt -f markdown -o book.epub --toc --metadata title="My Book" --metadata author="Your Name"

Pandoc starts a new chapter file at each top-level heading by default, and --toc builds the contents list. Its manual lists the EPUB options, including how to control the heading level used for splitting. Because Pandoc reads the file as Markdown, characters like * and _ in your text can be read as formatting. Escape them or check the output.

What heading patterns do converters recognise?

Converters generally recognise short lines that start with a word like "Chapter", "Part" or "Book" followed by a number, or lines marked with Markdown #. The exact list differs by tool, which is why a single consistent pattern works best.

Which pattern you should use depends on your file:

Your headings look likeRiskWhat to do
Chapter 12 or Chapter 12: TitleLowKeep as is
CHAPTER TWELVEMediumWorks in many tools, but add a consistent pattern if detection misses any
12. or XII aloneHighRewrite as Chapter 12, or mark with #
Titles with no number or keywordHighMark each with #
* * * scene breaksNot chaptersLeave as is, or replace with a blank line and a centred break in an editor afterward

Don't mark scene breaks, epigraphs or "Contents" lists as headings. A false chapter creates a clutter entry in the TOC. If your file begins with a typed list of chapters, delete it, because the EPUB generates its own.

How do I check the chapters worked?

Open the EPUB in a reader and open its table of contents. Every chapter should be listed in order, tapping an entry should jump to the right place, and no entry should land mid-paragraph.

Run through this checklist:

  • Count the entries. Compare the TOC to the number of chapters you expect. Far too few means detection missed headings. Far too many means it treated something else as a heading.
  • Tap the first, a middle and the last entry. Each should open on the chapter's title.
  • Look at paragraph spacing. Paragraphs should be distinct, with no single words stranded on their own lines.
  • Check special characters. Scan for quotes, apostrophes and accents.
  • Change the font size. Text should reflow. This is the whole point of the conversion.

If the contents list is empty or broken, our guides on how a PDF to EPUB table of contents is built and fixing a missing TOC explain how the navigation file works. They are written about PDFs, but the EPUB structure is the same.

Once your EPUB is ready, you can send it straight to a Kindle. We cover that in how to send an EPUB to your Kindle. If your TXT file needs chapters and you'd rather not set up Calibre or Pandoc, Convert2EPUB can convert it in your browser.

Frequently asked questions

Can I convert a TXT file to EPUB for free?

Yes. Calibre and Pandoc are both free, and Convert2EPUB lists its Standard conversion as free for text files. Check the current limits on the pricing page before you start a large batch.

Why does my EPUB have no chapters after converting from TXT?

Usually the converter didn't recognise your headings. Make every chapter title a short line of its own, in one consistent pattern such as Chapter 1: Title, or mark each with #, then convert again.

Why is every line of my converted book broken in the wrong place?

The source file is hard-wrapped, meaning a line break was inserted at the end of every line. Join each paragraph into one line before converting, keeping a blank line between paragraphs.

Does a TXT file keep bold, italics or images?

No. Plain text has no formatting, so nothing is lost on conversion, but nothing is added either. If you want italics or bold, add Markdown markers like italic and use a Markdown-aware converter, or start from a Word file. See converting DOCX to EPUB.

Will the EPUB work on a Kindle?

Amazon's Send to Kindle accepts EPUB files, and Convert2EPUB's own page says it takes an EPUB as it is. In most cases you don't need to convert to MOBI or AZW3. Our EPUB to MOBI and AZW3 guide explains when you would.

Ready to convert your own PDF? It's free for ordinary text documents, no account required.

Convert a PDF to EPUB →