Book4matter

Book4matter Home Page

Write in Markdown. Publish everywhere. Book4matter (Book Formatter) takes in Markdown, or plain text, and formats it for distribution. It uses this one source to produce output in HTML, EPUB, PDF and print versions. (PDF versions have clickable links, print has page references).

It was built to take a manuscript to Amazon KDP without worrying about formatting while you are writing.

Book4matter is available as a web app, a prebuilt docker container and as source.

The web version is at app.book4matter.com.

Source for web version: Book4matter-web GitHub.

You can get a docker container for Book4matter with

docker pull book4matter/book4matter

Or just pull the source, and install it locally. Source for command line version: Book4matter GitHub

Full User Manual is available here: examples/docs/book4matter.html

This webpage is rendered by Book4matter. It was written in Markdown.

TBH, Book4matter is not really designed to be a website builder. But using it to build its own website seemed reasonable.

Part 1 Overview

Chapter 1 Why it exists

Book4matter lets you keep your text, and the formatting separate:

Point ten books at one style file and restyle them all from a single edit. The manuscript never changes.

Part 2 One source, four outputs

Every output is generated from the same Markdown, so they never fall out of sync.

Chapter 3 Shareable PDF

The same book with live, clickable hyperlinks and a linked table of contents — the version you email or post, not the one you send to a printer. This version can include a cover image, if you want.

Chapter 4 EPUB

A reflowable e-book that passes the W3C EPUBCheck validator (the same class of checks KDP runs on upload), so most rejections are caught before you ever upload.

Note: Each EPUB publisher has different requirements. They restrict things like manuscript length, image size, and even limits on references to other publishers. You’ll want to check these out, before publishing.

Chapter 5 Website

One self-contained HTML page with an automatic table of contents and your own stylesheet

This is how this website was generated.

Part 3 Examples: see it in action

These three books are built by this same pipeline on every commit, in all four forms. Everything below came from Markdown — no hand-editing of the output.

Chapter 6 The user manual

The Book4matter User Manual explains how to write, configure, and build your books. It is also a working example of the tool documenting itself.

Chapter 7 The demo

The Pocket Pipeline — a short worked example that exercises the features.

Chapter 8 A novel

The Smallest Fire — An example to show the pipeline on plain text input. (AI generated)

Part 4 Quick start

The quickest way to run Book4matter is the prebuilt Docker image: nothing to clone, and nothing to install but Docker itself — no pandoc, no Typst, no fonts to hunt down. (Prefer to install the tools directly, or build the image yourself? The manual covers all three ways.)

Chapter 9 Install Docker

https://docs.docker.com/engine/install/

Chapter 10 Get book4matter

Pull the image from Docker Hub:

docker pull book4matter/book4matter

You can see the entry for book4matter on docker hub.

Chapter 11 Make a book

A book is just a directory:

my-book/
  book_metadata.yaml    # title, author, rights
  book_style.yaml       # trim, margins, fonts
  chapters/
    010-first.md
    020-second.md

Chapters are combined in filename order, so a numeric prefix controls the sequence.

Chapter 12 Build it

Mount the folder that holds your book at /work and name the form you want. Everything after the image name is an ordinary bf command:

docker run --rm -v "$PWD":/work book4matter/book4matter print my-book/   # KDP print interior PDF
docker run --rm -v "$PWD":/work book4matter/book4matter pdf   my-book/   # shareable PDF with live links
docker run --rm -v "$PWD":/work book4matter/book4matter epub  my-book/   # validated EPUB
docker run --rm -v "$PWD":/work book4matter/book4matter html  my-book/   # single-page website

Each command writes into my-book/out/; the tool only ever writes there, never back over your manuscript.

Part 5 What you get

Chapter 13 Real book typography

Powered by Typst under the hood: proper hyphenation and justification, small title/copyright/contents front matter, running heads, and quality book faces (Libertinus Serif for text, a Helvetica-metric sans for headings) bundled right in the image — no font wrangling. You can use your own fonts, too, of course.

Chapter 14 KDP Support

Trim sizes, gutter margins that scale with page count, and an EPUB that clears the same validator KDP uses. The defaults aim at a US 6×9 trade paperback that uploads clean.

Chapter 15 Markdown you already know

Standard Pandoc Markdown: headings, emphasis, lists, block quotes, footnotes, tables, images, and hyperlinks. Plain .txt works too, for novelists who want nothing but words and scene breaks.

Chapter 16 Novels and non-fiction alike

Treat top-level headings as parts (or sections) with chapters beneath, or flip a switch and let them be numbered chapters in a novel with no visible headings at all.

Chapter 17 Import from Word

Already have a .docx? Book4matter can import it, split it into chapter files on its headings, and pull the embedded images out for you — a running start instead of a blank page.

Chapter 18 Reproducible by design

You can run everything from a pinned Docker image. No host installs, no network at build time, and the same inputs produce the same outputs on any machine.

If you want more control, you can install locally, or you can build the docker image locally, and run that way.

Chapter 19 Afterword

Book4matter is a thin pipeline over two excellent tools, wired together so you never have to touch either directly.

  1. Pandoc reads your Markdown and your two YAML config files.
  2. For print and PDF, Pandoc emits Typst, and Typst does the page layout — margins, running heads, hyphenation, front matter.
  3. For EPUB and HTML, Pandoc writes those directly, sharing the same metadata and styling decisions.

Because the styling lives outside your prose, the same manuscript flows into every format without edits, and one change to a style file re-themes every book that points at it.

Learn more

The full manual — installation, configuration, every command, and the design decisions behind the defaults — is itself a Book4matter book. Read it online, build it from the docs/ directory, or read the source in the repository.

Book4matter is a command-line tool, and open source. If you’re comfortable in a terminal and want your words to look like a real book, it’s built for you.

Part 6 Why Choose Book4matter

Book4matter is open source. We want you to use us, if we are the right choice for you. If another tool works better for you, that’s fine with us. Here are some of the popular alternatives, and why you might to use them vs. book4matter.

Chapter 20 Book4matter Advantages

  1. It’s open source. If you don’t like the way something works, you can change it.
  2. You can use your favorite editor. While many tools with editors allow you to import, they usually assume you will import once, and work in their editor from that point on. Why would you want to learn a new editor?
  3. Automation. The command line version can be automated. For example, you can have your book automatically republised whenever you make a change. Or you can automatically apply formatting changes to multiple books.
  4. You can work in text or markdown which work well with version control systems, like git. While these are generally only used by technical folk, being able to track changes is highly useful. And git plays well with automatically publishing a new version of your book, when changes are made.
  5. Web app or command line. You can use book4matter without installing anything, or you can run the command line version on your local machine. The choice is yours.

Chapter 21 Advantages of Other Tools

Many of the alternatives have a broader ranges of predesigned styles for books. Book4matter give you a lot of control, but only one default style.

Paid tools frequently come with customer support.

Some have local applications you can run, which can give a nicer interface than a web app.

Chapter 22 Alternative Tools

Vellum

Vellum is a commercial Mac application supporting editing and formatting. It’s very easy to use, and has great support and a lot of premade styles. It also makes specific ebooks for each of the major publishing platforms, like Amazon, Apple, Google, Kobo, etc., which all have slightly different requirements.

While you can import, they really expect you will import once, and issues come up when you want to keep working with your preferred editor.

Atticus

Atticus is a web app, like book4matter. It combines editing and formatting across Windows, Mac, Linux, and Chromebook. It offers manuscript import, ebook and print output, ready-made templates, a custom theme builder, and customer support.

Draft2Digital

Draft2Digital converts uploaded manuscripts into EPUB and print-ready PDF, with free downloads even if you don’t distribute through the service. It is useful for authors who want straightforward conversion and optional retailer distribution without adopting a writing editor. The tradeoffs are reliance on an online service and less direct layout control than a customizable typesetting pipeline. Distribution is a separate consideration: commissions and account fees apply under its publishing terms.

Reedsy

Reedsy Studio combines browser-based writing, editing, collaboration, and formatting, with manuscript import and EPUB and print-ready PDF exports. Its core writing and formatting features are free, making it an accessible option for authors who want a shared workspace. The tradeoffs are reliance on a hosted application, formatting within its provided design options, and paid plans for some additional writing and planning features.

Pandoc + Typst

Book4matter is just a coordination layer for pandoc and typst, with functions for writing books, like indexes, chapters. You could use Pandoc and Typst to do the same. Even if you don’t program, you can have an AI set it up for you. Or just grab the Book4matter source, and make the changes you want.