Convert Markdown files, specs, or documentation folders into clean, Kindle and E-Ink optimized EPUB 3 e-books that pass Amazon Send-to-Kindle conversion. Use when the user asks to turn Markdown into an EPUB, prepare a document for Kindle/e-reader reading, or package technical docs with tables, code blocks, callouts, footnotes, or Mermaid diagrams into an e-book.
Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of Md To Epub?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/mrmike-md-to-epub)
---
name: md-to-epub
description: >-
Convert Markdown files, specs, or documentation folders into clean,
Kindle and E-Ink optimized EPUB 3 e-books that pass Amazon
Send-to-Kindle conversion. Use when the user asks to turn Markdown into
an EPUB, prepare a document for Kindle/e-reader reading, or package
technical docs with tables, code blocks, callouts, footnotes, or Mermaid
diagrams into an e-book.
license: Apache-2.0
compatibility: >-
Requires Python 3.9+ (stdlib only; zero required dependencies). Optional:
mmdc or merman-cli for offline Mermaid PNG rendering; Pillow for transparent
PNG flattening and screen-fit image downscaling; network access if using
Kroki/mermaid.ink remote Mermaid rendering.
metadata:
author: md2kindle
version: "1.0.0"
---
# Markdown to Kindle-Ready EPUB 3
Convert one or more Markdown files (or a directory of `.md` files) into a validated, E-Ink–friendly EPUB 3 file tailored for Kindle displays and Amazon's Send-to-Kindle (KFX) converter.
## Procedure
1. **Locate inputs and output path**
- Identify the Markdown file(s) or folder to convert and choose an output `.epub` path (defaults to `<input>.epub`).
- Check if the user wants a custom `--title`, `--author`, `--cover`, `--screen-size`, or `--offline` mode (private docs should use `--offline` or `--mermaid local` so Mermaid diagram source is not sent to remote rendering APIs).
2. **Run the converter script**
Execute [scripts/md_to_epub.py](./scripts/md_to_epub.py) with Python 3:
```bash
python3 scripts/md_to_epub.py <input.md> -o <output.epub>
```
Useful flags:
- `--title "My Spec"` / `--author "Name"` — override inferred frontmatter/H1 metadata.
- `--split-level 2` (default) — splits single Markdown files on H1/H2 into Kindle chapters with TOC entries (`0` = single chapter, `1` = H1 only).
- `--screen-size standard` (default) — sets Kindle screen-size class for auto table reflow, Mermaid PNG sizing, and optional Pillow image downscaling (`compact` = 6" / 1072×1448, `standard` = 7" / 1264×1680, `large` = 10"+ / 1860×2480).
- `--table-mode auto` (default) — automatically turns wide tables into stacked key-value cards sized to `--screen-size` (`cards` or `table` to override).
- `--mermaid auto|local|kroki|ink|none` — renders Mermaid fenced blocks to opaque-white PNGs (`local` uses `mmdc`/`merman-cli`; `auto` falls back to Kroki POST API unless `--offline` is passed; always falls back safely to a code block on failure).
- `--code-wrap 0|auto|N` — hard-wrap long code lines (`0` = soft CSS `pre-wrap` [default]; `auto` = match `--screen-size`; or explicit column count like `52`).
- `--cover path/to/cover.jpg` — embed a raster cover image (sets both EPUB 3 `cover-image` and EPUB 2 `<meta name="cover">`).
3. **Verify validation output**
- Built-in validation runs automatically by default and checks:
- `mimetype` is entry 0, uncompressed (`ZIP_STORED`), empty extra field, exact `application/epub+zip`.
- Every `.xml`, `.opf`, `.ncx`, and `.xhtml` file is well-formed UTF-8 XML without BOM or named entities like ` `.
- Both `nav.xhtml` (EPUB 3) and `toc.ncx` (Kindle Go-To TOC) exist.
- No Kindle E016 hazards (`<menclose>`).
- If the user wants to deliver the generated `.epub` to their Kindle, hand off to the optional `send-to-kindle` skill (if installed) or provide the local path for `amazon.com/sendtokindle`.
## Reference
- For detailed Amazon Send-to-Kindle KFX rules, E-Ink CSS constraints, pop-up footnotes, and diagram tips, read [references/kindle-epub-guide.md](./references/kindle-epub-guide.md).