guidetutorial12 min read

Markdown to EPUB: Publish a Book from Your .md Files (2026)

Markdown to EPUB is the indie author's quietest superpower. Chapters as files, one command, a book on Apple Books by sundown.

Mohammed AgratUpdated May 26, 2026

Markdown to EPUB is the publishing pipeline indie authors use when they want their book to look like a book and ship before the next rewrite. Plain-text chapters, one conversion command, an EPUB validates, and KDP accepts the upload. No InDesign, no Word manuscript template, no formatter on Fiverr.

TL;DR

  • Yes, you can publish a real book from markdown. KDP, Apple Books, Kobo, and Google Play Books all accept EPUB; markdown is the cleanest way to get there.
  • The standard stack: Pandoc converts, Calibre polishes, EPUBCheck validates, KDP / Apple Books / Kobo distribute.
  • One file per chapter,numbered. The folder is your manuscript’s spine.
  • Metadata is non-negotiable.Title, author, language, identifier, cover. Stores accept without; readers don’t find you without.
  • Want a print edition too? The same markdown exports to a designed PDF via mdclaudy’s manuscript template.

The state of markdown → EPUB in 2026

EPUB is the open standard for ebooks. It’s a zip file containing XHTML, CSS, images, and a manifest. Reading apps — Apple Books, Kindle (via conversion), Kobo, Adobe Digital Editions, every browser-based reader — understand it. The current spec is EPUB 3.3, published by the W3C in 2023.

Three tools matter for the markdown-to-EPUB route:

  • Pandoc — the universal document converter, free, command-line. Maintained by John MacFarlane since 2006. The reference tool for markdown to almost any format.
  • Calibre — the open-source ebook library manager with built-in conversion, cover designer, and metadata editor. GUI-friendly. Indispensable for the polishing phase.
  • mdclaudy — the editor and conversion path described in this post. Designed templates for the print PDF counterpart; clean EPUB output for the digital one.

Online generic converters exist — Vertopal, Zamzar, CloudConvert— and they will technically produce an EPUB from a markdown file. They don’t handle chapter structure, metadata, or covers. They produce a single-chapter ebook with a generic title. Useful for a one-off test; not the right tool for a book you’re selling.

The folder structure of a book

Before writing a line, set up the file system. Books that ship cleanly almost always look like this:

my-novel/
├── meta.yml
├── cover.jpg
├── chapters/
│   ├── 00-title-page.md
│   ├── 01-copyright.md
│   ├── 02-dedication.md
│   ├── 03-prologue.md
│   ├── 04-chapter-one.md
│   ├── 05-chapter-two.md
│   ├── ...
│   ├── 30-epilogue.md
│   ├── 31-acknowledgments.md
│   └── 32-about-the-author.md
└── images/
    └── map.png

Numbering is for sort order — Pandoc concatenates in alphabetical order when you pass *.md. Leave gaps (10, 20, 30) so you can drop a chapter in later without renumbering. mdclaudy uses a collection with drag-to-reorder instead, but the underlying principle is the same: one chapter, one file, the order is the book.

EPUB metadata — the fields that matter

EPUB metadata lives in the content.opf manifest. With Pandoc, you write it in YAML and pass --metadata-file=meta.yml. The minimum viable file:

---
title: The Quiet Garden
author: Mohammed Agrat
language: en
identifier:
  scheme: ISBN
  text: 978-1-234567-89-0
date: 2026-05-26
publisher: Independent
rights: © 2026 Mohammed Agrat. All rights reserved.
description: |
  A novel about a botanist who inherits a house with a garden
  that refuses to grow anything she plants.
subject:
  - Fiction
  - Literary fiction
  - Magical realism
cover-image: cover.jpg
---

Two metadata details that actually move sales:

  • Subject tagsmap to BISAC categories on Amazon and BIC categories on European stores. They drive which-bestseller-list-you-appear-on. Pick the most-specific subcategory you legitimately fit — “Literary fiction” beats “Fiction”, “Coming of age” beats “Literary fiction”.
  • Description is your back-cover blurb. Stores display it verbatim. 150–200 words; first sentence does the lifting.

The cover image

Specs the major stores agree on:

  • Dimensions: 1600 × 2400 pixels (2:3 aspect), minimum. KDP recommends 2560 × 1600 minimum on the long edge.
  • Format: JPG or PNG. JPG for photo-based covers, PNG for graphic covers with sharp lines.
  • File size: under 50MB. Most covers come in under 2MB.
  • RGB, not CMYK. CMYK will render wrong in reading apps.
  • Title and author must be legible at thumbnail size (160×240 on a phone). This is the most-violated rule in indie publishing.

Tools: Canva, Affinity Publisher, Adobe InDesign, or a designer on Reedsy($200–800 for a cover that won’t look like a self-published cover). The cover is the only piece of design that genuinely matters for sales; spend on it.

The conversion command

Pandoc’s entire markdown-to-EPUB command, fully loaded:

pandoc \
  --from gfm \
  --to epub3 \
  --metadata-file=meta.yml \
  --epub-cover-image=cover.jpg \
  --toc \
  --toc-depth=2 \
  --epub-chapter-level=1 \
  --css=epub.css \
  --output=quiet-garden.epub \
  chapters/*.md

Two flags worth understanding:

  • --epub-chapter-level=1: every # heading (H1) becomes a new chapter file inside the EPUB. Use H1 only for chapter titles; use H2 for in-chapter section breaks.
  • --toc --toc-depth=2: generates a clickable table of contents at depth 2 (chapters + first-level sections). Most readers want this.

The optional epub.css file lets you control typography inside the EPUB — line height, font choice for body and headings, chapter heading style. Reading apps will override font choices if the reader has theirs set, but spacing and structural CSS sticks.

The mdclaudy export path

mdclaudy ships EPUB export from any collection. The flow:

  • Create a collection. Drag your chapter documents in. Reorder.
  • Open the collection’s export panel. Pick EPUB.
  • Fill in metadata (title, author, ISBN, description, subject tags). Upload a cover image.
  • Export. mdclaudy runs the conversion server-side with Pandoc under the hood, validates with EPUBCheck, and hands you a finished EPUB.

The point of doing this in mdclaudy instead of by hand: the same collection also exports to a designed PDF for the print edition. The markdown stays the source of truth; the EPUB and the print PDF are two renders of the same document.

Validation: run EPUBCheck before you upload

EPUBCheck is the W3C’s reference validator. Every store runs their own version on upload; failing validation means rejection. Save the round trip by running it locally:

# install
brew install epubcheck   # Mac
npm install -g epubcheck # cross-platform via Node

# run
epubcheck quiet-garden.epub

Pandoc-generated EPUBs almost always pass. The common failure modes when they don’t: missing alt text on cover image, an image reference that doesn’t exist on disk, a malformed YAML metadata field. Read the error, fix the source, re-run.

Upload: where to put your finished EPUB

Three strategies for distribution:

  • Amazon KDP exclusive— enroll in Kindle Unlimited, collect “page reads” revenue, accept 90 days of Amazon exclusivity. Worthwhile if you write in genres where KU readers live (romance, thriller, fantasy). Less compelling for literary fiction.
  • Wide distribution, direct uploads— KDP, Apple Books, Kobo, Google Play Books, Barnes & Noble Press. Five uploads, five dashboards, five royalty rates. Maximum control, most admin.
  • AggregatorsDraft2Digital (free, takes ~10% royalty cut after store cut) or PublishDrive distribute one upload to every store including library systems. Simpler. Slightly lower per-sale royalty. Most indie authors run KDP direct + Draft2Digital for the rest.
Markdown is the indie author’s least romantic, most useful decision. The romance lives in the prose, not in the file format.

The print companion to a digital EPUB is a designed PDF — fixed-page layout, real typography, trim size matching your printer’s spec (KDP Print accepts 5x8, 5.25x8, 5.5x8.5, 6x9, and a few more).

This is the gap mdclaudy was built to fill. The same markdown chapters that produce your EPUB also export through the Manuscript template — ligatures, drop caps, page numbers, chapter openers, running heads. Upload the PDF to KDP Print or IngramSpark for a hardcover or paperback companion.

We wrote a full walkthrough in the markdown to PDF guide covering trim sizes, bleed, ISBN considerations, and the Quick vs Print-Quality engine choice.

Real example: a 75,000-word novel shipping checklist

What an indie author’s ship-the-book Tuesday actually looks like:

  • 9:00am — final manuscript read-through complete. 75,000 words across 28 chapter .md files in a folder.
  • 9:30 — write meta.yml with title, author, ISBN (purchased separately from Bowker), description, subject tags. 15 minutes.
  • 9:45 — finalize cover image (already designed weeks ago). Drop into project root as cover.jpg.
  • 10:00 — run Pandoc. EPUB generated in 4 seconds.
  • 10:01 — EPUBCheck. Clean.
  • 10:05 — sideload to Apple Books and Kindle Previewer. Read the first chapter on each. Catch one footnote that lost a period. Fix the source, re-run.
  • 10:30— generate the print PDF via mdclaudy’s Manuscript template. Quick proof read.
  • 11:00 — upload EPUB to KDP. 24-hour review window.
  • 11:15— upload EPUB to Draft2Digital. Configures Apple Books, Kobo, Google Play, B&N in one form.
  • 11:45 — upload print PDF + cover wrap to KDP Print. 72-hour review window.
  • 12:00 — lunch. Book ships in 1–3 days.

Frequently asked questions

Can I publish a book written in markdown?

Yes — and this is one of the cleanest publishing pipelines that exists. Write each chapter as a .md file, convert the folder to EPUB with Pandoc or mdclaudy, validate with EPUBCheck, upload to Amazon KDP, Apple Books, Kobo, or Google Play Books. Brandon Sanderson, Cory Doctorow, and a long tail of indie authors ship books this way. The format strips you down to the words, which is exactly what a novel wants.

Pandoc or Calibre for markdown to EPUB?

Pandoc for the actual conversion — it has the cleanest markdown understanding and produces validator-clean EPUBs. Calibre for cover design, metadata editing, format conversion (EPUB → MOBI for older Kindles), and as a library manager. The standard indie pipeline runs both: Pandoc to produce the EPUB, Calibre to polish and convert.

Does Kindle accept EPUB now?

Yes, as of 2022. KDP accepts EPUB uploads directly and converts to KFX (the modern Kindle format) on its end. You no longer need to produce MOBI files unless you’re sideloading to a pre-2020 Kindle device. Apple Books, Kobo, Google Play Books, and every independent bookstore have always accepted EPUB.

What metadata does my EPUB need?

At minimum: title, author, language (ISO code, e.g. en), and a unique identifier(your ISBN, or a UUID if you don’t have one). Strongly recommended: cover image (1600×2400, JPG or PNG), publication date, description, publisher, rights (copyright line), and subject(genre keywords). Stores won’t reject without the optional fields, but discoverability suffers.

How do I add a cover to a markdown-generated EPUB?

Pandoc’s --epub-cover-image=cover.jpgflag does it in one line. mdclaudy’s EPUB export lets you upload a cover image and embeds it as the first page plus the metadata thumbnail. If you’re hand-editing, the cover lives in the EPUB’s OEBPS folder and is referenced from content.opf. Use Calibre’s cover editor if you’d rather not touch the internals.

What's the right chapter file structure?

One markdown file per chapter, numbered for sort order: 01-prologue.md, 02-chapter-one.md, 03-chapter-two.md. Add a 00-frontmatter.md for title page, copyright, dedication; a 99-backmatter.md for acknowledgments, about-the-author, also-by. Pandoc concatenates them in alphabetical order; mdclaudy lets you drag-reorder a collection. Either way, the file system is your manuscript’s spine.

Will my markdown footnotes survive the EPUB conversion?

Yes, with Pandoc — it’s the gold standard for footnote and endnote handling. Each footnote becomes a linked superscript with a return arrow back to the source. mdclaudy preserves footnotes the same way. Calibre’s built-in conversion is less reliable on complex footnote structures; if your book has heavy citation density, route through Pandoc.

Can I sell a markdown-generated EPUB on Amazon?

Yes. The store doesn’t care how you authored the book — only that the EPUB validates and the metadata is complete. Run EPUBCheck before uploading (Pandoc-generated EPUBs almost always pass), upload to KDP, set your price, and Amazon converts to KFX on their end. Self-publishing has zero technical gatekeeping at the format level.

The honest summary

Markdown to EPUB is the indie publishing pipeline you wish someone had described to you ten years ago. The conversion is one command. The validator is free. The stores accept it. The format costs nothing. The only friction is writing the book.

And the print companion — the trim-sized PDF that goes to a KDP Print or IngramSpark order — is the same markdown, exported through a template designed by someone who cared. That’s what we built mdclaudy for. Write once, ship in three formats.

─── try mdclaudy ───

Write markdown. Ship a designed PDF.

Fifteen hand-built templates. Optional AI. Free up to 50 documents.

No card. 50 documents included.
─── Related reading