Batch Convert Markdown to PDF: Browser ZIPs, CLI, Pandoc, and CI
Batch export up to 15 Markdown files to a ZIP in the browser, automate separate PDFs with a CLI, or combine chapters with Pandoc.
On this page
01The 30-second answer02Scenario 1 — N → N (one PDF per Markdown file)03When to use the web tool vs the CLIThree common batch jobs:
- One Markdown file → one PDF, repeated for many files:
md-to-pdf *.md(npm CLI). - Many Markdown files → one combined PDF (a book, a report with chapters):
pandoc chapter*.md -o book.pdf. - Many Markdown files → one PDF on each commit: GitHub Actions workflow with the npm CLI.
There is also a browser route: use Batch export for separate outputs without installing a CLI. The individual /markdown-to-pdf page remains useful for one document. Choose browser batch, local automation, or a combined PDF according to the deliverable.
Open Batch export, upload up to 15 Markdown files, choose PDF and shared rendering settings, then run the export. PNG, JPEG, WebP, PDF, and DOCX are supported output formats. This is a paid feature; Creator includes 20 batch runs each month.
The ZIP contains one output per successful input. If a file fails, inspect its .error.txt note rather than assuming the entire batch succeeded. A run with at least one successful file consumes one batch run. A ZIP containing 15 PDFs is still 15 separate documents, not a single 15-chapter PDF.
Use the fixture below as one of the input files. Compare its heading, checklist, and final note with its exported preview and downloadable PDF; then inspect the remaining files individually.
# Chapter 01: export checks
## Scope
This sample represents one source file in a multi-file export.
- Keep one output per input file
- Check every generated file
- Inspect the ZIP for error notes
> A ZIP of PDFs is different from one merged PDF.
The simplest case. You have chapter01.md, chapter02.md, ..., and you want chapter01.pdf, chapter02.pdf, ...
npm install -g md-to-pdf
md-to-pdf 'chapters/*.md'
That's it — by default it writes a .pdf next to each .md. Add a stylesheet to control look:
md-to-pdf 'chapters/*.md' --stylesheet ./style.css
If you have hundreds of files and want to parallelize:
find chapters -name '*.md' -print0 | xargs -0 -P 4 -I {} md-to-pdf '{}'
Start with low concurrency and increase it while observing CPU and memory; each worker may start a browser process.
This is what you want for books, technical reports, or onboarding docs split across files.
pandoc chapter01.md chapter02.md chapter03.md -o book.pdf
Gotcha: filename order matters. Pandoc concatenates in argument order, not alphabetical, so use shell expansion intentionally:
pandoc chapter*.md -o book.pdf # alphabetical order, fine if you've zero-padded
For a table of contents:
pandoc chapter*.md --toc -o book.pdf
Select chapter-level divisions, then check a compatible PDF engine and template:
pandoc chapter*.md --toc --top-level-division=chapter -o book.pdf
If you don't want to install Pandoc, concatenate first:
: > combined.md
for f in chapter*.md; do
cat "$f" >> combined.md
printf '\n\n<div style="page-break-before: always;"></div>\n\n' >> combined.md
done
md-to-pdf combined.md
The inserted HTML is a page-break hint for the HTML/Chromium rendering path used here. Check the generated PDF; raw HTML and print CSS are not interpreted identically by every Markdown converter.
A GitHub Actions workflow that produces PDFs on every push to main:
# .github/workflows/build-pdfs.yml
name: Build PDFs
on:
push:
branches: [main]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 24
- run: npm install -g md-to-pdf
- run: md-to-pdf 'docs/**/*.md'
- uses: actions/upload-artifact@v4
with:
name: pdfs
path: 'docs/**/*.pdf'
This runs md-to-pdf on every Markdown file under docs/, uploads the PDFs as a build artifact. Trigger on tag push and you can attach them to a Release.
- Image paths break in the combined PDF. If
chapter01.mdreferences./images/a.pngfrom inside its own directory, concatenating into a single file breaks that path. Either rewrite paths to be absolute, embed images as data URIs, or use Pandoc's--resource-path=.to add lookup directories. - Front matter. Pandoc lets a later YAML metadata block override the same field in an earlier block. Consolidate book-level metadata deliberately; see the metadata rules.
- Page numbering.
--top-level-division=chapterchanges heading division type, not page-number policy. Configure pagination in the chosen engine/template and inspect the PDF; see division options. - Unicode and CJK fonts. With Pandoc and XeLaTeX, set an installed font explicitly, for example
--pdf-engine=xelatex -V mainfont:"Source Han Serif CN". Local Chromium tools use fonts available in their runtime. For hosted rendering, test the service font coverage with the exact characters you need. - Memory for large batches. Browser-based conversion is resource-intensive. Bound concurrency, monitor memory, and split very large jobs into resumable chunks.
- One document →
/markdown-to-pdf. - Up to 15 files with common settings → paid Batch export.
- Repeat on each commit → CLI in CI.
- One book with ordered chapters → Pandoc with
--top-level-division=chapter --toc. - Existing PDFs with different layouts → merge with
pdfuniteorqpdf.
For more on each tool's tradeoffs see our Markdown to PDF method comparison and the deep dive on code highlighting in PDF.
If separate PDFs already exist, choose a page-assembly tool or a PDF rewrite according to your preservation requirements:
# pdfunite (poppler-utils)
pdfunite chapter01.pdf chapter02.pdf chapter03.pdf book.pdf
# or qpdf
qpdf --empty --pages chapter*.pdf -- book.pdf
# or ghostscript
gs -sDEVICE=pdfwrite -dNOPAUSE -dBATCH -sOutputFile=book.pdf chapter*.pdf
Use pdfunite or qpdf for page assembly. Ghostscript pdfwrite creates a new PDF rather than a lossless concatenation. Check fonts, links, bookmarks, and image compression afterward; see the device documentation.
Can I batch-export in a browser?
For several files, open Batch export: this paid tool accepts up to 15 Markdown files per run and downloads a ZIP with one output per input. Creator includes 20 runs per month. Select PDF for separate PDFs; use Pandoc when you need one combined document.
How do I preserve code highlighting across all files in batch mode?
The CLI inherits whatever stylesheet you pass with --stylesheet. Use the same theme on every file for consistency. Read more in Markdown to PDF with code highlighting.
What's the upper limit on a single combined PDF?
There is no universal page limit: memory, images, fonts, renderer, and PDF viewer all matter. Test representative large documents, set CI timeouts, and split very large manuals into volumes.
Does Pandoc preserve Mermaid diagrams in batch mode?
Check the chosen renderer rather than assuming Mermaid fences will become diagrams. For the local recipes, pre-render diagrams as image assets or configure supported preprocessing. Inspect the final PDF for missing or clipped diagrams.
The right batch tool depends on what you're producing:
- Separate files in one ZIP → paid Batch export.
- Scripted one-to-one PDFs →
md-to-pdf '*.md'. - Many-to-one book →
pandoc chapter*.md --toc -o book.pdf. - Continuous build → GitHub Actions + CLI.
- Existing PDFs →
pdfuniteorqpdf.
For an occasional group of files, start with browser batch and inspect the ZIP. It does not merge its PDFs into one document. If one combined PDF is the requirement, use the ordered Pandoc recipe above or merge already exported PDFs with a dedicated tool.
The product limits and commands above were checked against these current primary sources:
Open MarkdownToImage to render Markdown, then choose the output format that matches your workflow. Test one representative document before automating a batch.