MarkPrep
All posts
Published · Updated · 6 min

Ebooks for AI: Getting a Whole Book Into Your LLM

To get a whole book into an LLM, convert the EPUB to Markdown, then split it into chunks by chapter and section. An EPUB file is a zip package, and an LLM needs the text inside it, so the package has to be unpacked first. Of all the formats, ebooks are among the easiest to convert. The harder problem is the size of a book. Books worth converting this way include a technical manual, a reference text or a public-domain classic you are studying.

How EPUB to Markdown conversion works

Open an .epub and you find a zip of HTML files, one or more per chapter, plus a manifest that lists the reading order. HTML is already structured text, with headings, paragraphs, lists and emphasis marked up. So converting an EPUB to Markdown means walking the chapters in order and mapping each one's HTML to Markdown. Web pages convert the same way, because they are HTML too.

MarkPrep's EPUB to Markdown converter reads the package, follows the manifest's reading order and joins the chapters into one Markdown file. When a chapter has no heading of its own, MarkPrep adds one from the chapter file's title.

The real challenge: a book is huge

A full-length book is long even for a large context window. If you send the whole book with every question, the LLM reads every token of it each time. A long book can also go over the limit.

The usual answer is retrieval. Instead of pasting the whole book, you:

  1. Split it into chunks, ideally on chapter and section boundaries. The heading structure you kept makes this easy.
  2. Turn each chunk into an embedding and store it in a vector store, a database built for search by meaning.
  3. Retrieve only the relevant passages when you ask a question.

That is the RAG (retrieval-augmented generation) pattern. MarkPrep's chunk preview shows how the book will split before you embed it. Splitting on headings keeps each chunk a coherent passage instead of cutting mid-argument.

What to check in the converted EPUB

A few book-specific things to check in the output:

  • Chapter headings. Check that every chapter starts with a heading before you split the book.
  • Footnotes and endnotes. MarkPrep has no special handling for notes. The note text stays where the book stores it, and the note markers become links that won't open.
  • Images come out as Markdown image links pointing at files inside the EPUB, so those links won't open. Delete them if you only need the text.
  • Front matter (title page, table of contents) is usually noise for AI use and fine to trim.

Copyright, DRM and privacy

Converting a book to Markdown doesn't change what its copyright lets you do with the text. MarkPrep reads unencrypted EPUB files only. DRM is a separate lock, and the converter doesn't break it. The conversion happens in your browser and nothing is uploaded.

Next step

Convert the EPUB and check the chapter headings. Then plan the split in the chunk preview and export the chunks as JSONL for your vector store.

Try it on your own file

Convert a document and watch the token counter. It's free, needs no account and uploads nothing.