Skip to content
PDF to EPUB Converter
Menu

PDF to EPUB Converter / TXT to EPUB Converter

TXT to EPUB Converter

Drop a .txt file and get an EPUB with chapters. Encoding is detected, hard-wrapped lines become real paragraphs, and you can change the chapter pattern.

Choose a file to see the chapters that were found.

    How chapters are found

    1. Choose the .txt file. The page detects the text encoding and lists the chapters it found.
    2. Check the chapters. If the list is wrong, type a chapter pattern (a regular expression) and the list updates as you type.
    3. Set title and author. Leave them empty to use a title page at the top of the file, or the first line.
    4. Convert and download. The EPUB has one file per chapter and a table of contents.

    By default a line is a chapter heading when it matches one of these, case-insensitive: “Chapter 12”, “CHAPTER ONE”, “Chapter IV: The Return”, “Part 2”, “Book Three”, “第一章”, “Prologue”, “Epilogue”, “Preface”, “Appendix A”. A short line in capitals with a blank line above and below also counts, in a long text. If a file has no headings and is very long, it is cut into parts so your reader still has something to navigate by.

    Writing your own chapter pattern

    The pattern box takes a regular expression that is tested against each trimmed line, ignoring case. Some examples:

    • ^==\s*(.+?)\s*==$ matches “== Title ==” headings.
    • ^#\s+.+$ matches Markdown-style “# Title” lines.
    • ^\d+\.\s+[A-Z].{0,60}$ matches numbered headings such as “3. The harbour”.

    The matched line becomes the chapter title. An invalid pattern is reported and ignored.

    Paragraphs and line breaks

    Many text files are hard-wrapped at about 70 characters, so every line ends in a line break. The converter notices that and joins the lines of each block into one paragraph; a line ending in a hyphen is joined to the next word only when the joined word appears elsewhere in the text. Files that already have one paragraph per line are left alone. A title page of a few short lines at the top becomes the book title and, after “by”, the author.

    Encodings

    UTF-8 and UTF-16 (with or without a byte order mark) are detected automatically. Other files are read as Windows-1252, the common Western European encoding, or as GBK when the bytes look like Chinese text in that encoding. Other encodings may show wrong characters; open the file in an editor and save it as UTF-8 first.

    Questions people ask

    How do I turn a TXT file into an EPUB with chapters?
    Drop the file on this page. Lines such as “Chapter 1”, “CHAPTER ONE” or “第一章” become chapter headings, each chapter becomes its own file, and the table of contents is written for you. If your headings look different, type a pattern in the chapter box.
    Why are my paragraphs split into short lines?
    The text file was wrapped at a fixed width. This converter joins those lines back together when it detects wrapping. If your file is wrapped but has no blank lines between paragraphs, start each paragraph with an indent and it will use the indent.
    Which text encodings work?
    UTF-8, UTF-16 and Windows-1252 are detected, and GBK for Chinese text. If you see odd symbols, save the file as UTF-8 in a text editor and convert again.
    Can I add a cover image?
    Not in this converter. It makes a text-only EPUB. Most readers show a generated cover for books without one.
    How large a text file can I convert?
    Several megabytes is fine; the work happens in your browser tab, so very large files depend on your device’s memory.