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.
This webpage is rendered by Book4matter. It was written in Markdown. See our Github Project
TBH, Book4matter is not really designed as a website builder. But using it to build its own website seemed reasonable.
Book4matter is a command line tool, for now. It’s best for people who are comfortable with the command line.
Check back later for a web version.
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.
Every output is generated from the same Markdown, so they never fall out of sync.
A ready-to-print PDF.
I’ve used this for Amazon KDP, so it follows the rules there, like “no hyperlinks”.
External hyperlinks are reformatted to show the URL after the anchor text.
Book4matter (https://www.book4matter.com)
Internal links are converted to page number references
Book4matter on page 37
A table of contents is automatically generated. This PDF does not include a cover, since that is a separate upload on KDP.
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.
One self-contained HTML page with an automatic table of contents and your own stylesheet
This is how this website was generated.
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.
The book4matter manual — this tool documenting itself.
The Pocket Pipeline — a short worked example that exercises the features.
The Smallest Fire — fiction, to show the pipeline on plain prose.
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.)
https://docs.docker.com/engine/install/
Pull the image from Docker Hub:
docker pull book4matter/book4matter
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.
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.
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.
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.
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.
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.
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.
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.
Book4matter is a thin pipeline over two excellent tools, wired together so you never have to touch either directly.
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.
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.