Articles
Published · November 5, 2026

Turning Your Markdown Notes into an EPUB for Your E-Reader

Pandoc turns Markdown notes into an EPUB with one command. Here is how to prepare the files, set metadata, add a cover and a table of contents, and style the book.

Also in: Español中文हिन्दी

You can turn Markdown notes into an EPUB with a single pandoc command: pandoc notes.md -o notes.epub. The rest of this guide covers what to fix in your notes first, and the flags that give you a title, a cover and a table of contents.

Install pandoc and run the one-line conversion

Pandoc is a free command-line converter. Once it's installed, a basic EPUB takes one line, as pandoc's own ebook guide shows:

pandoc notes.md -o notes.epub

Pandoc writes EPUB3 by default. If your reader insists on the older format, ask for it with -t epub2. Because EPUB output is always standalone, you don't need the -s flag for the conversion itself.

If you've already exported a Markdown file to PDF or Word, this will feel familiar. Same tool, different output. We covered that when exporting a Markdown file to PDF and Word with pandoc.

Prepare your notes before converting

A note that reads well in an editor can look odd as a book. A short worked example from Ben Tasker lists the usual fixes:

  • Heading levels. Pandoc starts a new chapter at each level-1 heading by default. If your notes use ## for their top sections, shift every heading up one level.
  • Horizontal rules. Lines of --- between sections look wrong on an e-reader. Delete them.
  • Image paths. Pandoc resolves paths from the file's location, so use relative paths such as ./images/diagram.png. Local images are bundled into the EPUB automatically.
  • HTML anchors. A raw <a name="..."> on the line directly above a heading can stop the heading from rendering. Remove it or leave a blank line between them.

While you're tidying, it also helps to be consistent about which file extension to use for notes, since a build script will glob for it.

Set the metadata, cover and table of contents

A YAML block for the book

Put the book's details in a YAML block at the top of the first file. The pandoc manual lists the fields; these are the ones worth filling in:

---
title: "Field Notes"
author: "Your Name"
date: 2026-11-05
lang: en-US
rights: "© 2026 Your Name"
description: "Notes from the last year, collected as a book."
cover-image: cover.jpg
---

Pandoc fills in a title, creator, date, language and a generated identifier when you leave them out, so set at least the title and author. lang takes a BCP 47 tag such as en-US.

Cover image

Add a cover with --epub-cover-image=cover.jpg on the command line, or with cover-image in the YAML block as above. The manual suggests an image under 1000 pixels in width and height. Without one, the default cover is plain.

Table of contents

Turn it on with --toc, and choose how deep it goes with --toc-depth (the default is 3):

pandoc notes.md -o notes.epub --toc --toc-depth=2

The toc-title field renames the heading. If the book ends up as one huge chapter, --split-level controls the heading level at which pandoc splits it into separate files.

Combine several notes into one book

Pandoc accepts more than one input file and joins them in the order you list them:

pandoc title.md 01-intro.md 02-methods.md 03-results.md -o book.epub --toc

Keep the YAML block in title.md and number the other files so the shell lists them in reading order. If you are deciding how to cut a long manuscript up in the first place, see splitting a book-length Markdown document.

Style it with CSS and fonts

Pass a stylesheet with --css=book.css. Without one, pandoc uses a minimal epub.css from its data directory. To embed a font, add --epub-embed-font=MyFont.ttf and declare it in your CSS with an @font-face rule, since pandoc does not write that rule for you.

@font-face {
  font-family: "MyFont";
  src: url("../fonts/MyFont.ttf");
}
body { font-family: "MyFont", serif; }

Check the font path against the folder layout inside your EPUB; it can differ from what you expect.

Get it onto your e-reader and check it

Copy the file to your reader the way you normally load books, then open it and check the cover, the table of contents, a chapter break, and a page with an image. Animated GIFs only play if the reader supports them. If something is off, fix the Markdown and rebuild rather than hand-editing the EPUB. Ben Tasker notes that Calibre can edit a finished EPUB, which is useful for a one-off touch-up.

A tiny build script keeps the command in one place:

#!/bin/sh
pandoc title.md [0-9]*.md -o book.epub --toc --toc-depth=2 --css=book.css

Doing this with Carets

Pandoc does the conversion. Your editor does the writing and the tidying. Carets is a native notes and code editor for iPhone, iPad and Mac, and it keeps everything as plain Markdown files you can point pandoc at without exporting anything.

Three things help with this workflow:

  • Files, projects and tags. Keep a book's chapter files together in one project, numbered so they sort in reading order.
  • Markdown and plain text in one editor. Fix heading levels and image paths, and edit the YAML block, in the same app you write in.
  • Syntax highlighting. Your build.sh, CSS and YAML get highlighted, which makes a mistyped flag easier to spot.

Carets doesn't build EPUBs itself; you run pandoc for that. What it gives you is a fast place to prepare the source. Get Carets on the App Store for iPhone, iPad and Mac.

Frequently Asked Questions

Does pandoc make EPUB3 or EPUB2?

EPUB3 by default. Pass -t epub2 if your reader needs the older format.

How big should the cover image be?

The pandoc manual recommends an image under 1000 pixels in width and height. Pass it with --epub-cover-image or set cover-image in the YAML block.

Why does my EPUB come out as one long chapter?

Pandoc splits the book into files at level-1 headings by default. If your notes use ## for sections, shift the headings up one level or change --split-level.

Can I embed a custom font?

Yes. Use --epub-embed-font=FILE and add matching @font-face rules to the stylesheet you pass with --css.