5 Ways to Convert Markdown to PDF Compared (Pandoc, VSCode, Online Tools)
For most people, the browser-based /markdown-to-pdf is the right answer — 5 seconds, no install, full Markdown spec including code highlighting, KaTeX, and Mermaid. Pandoc is overkill unless you're publishing a book or paper. The other three methods exist for good reasons, but they're more niche than the internet suggests.
We benchmarked all five on a 30-page Markdown report with code blocks, math (KaTeX), tables, and a Mermaid diagram. Below is what we found, why each method exists, and where each actually wins.
Best for: One-off conversion, code highlighting, math, diagrams, no install.
How: Open /markdown-to-pdf, paste, click PDF.
Time to first PDF: ~5 seconds.
Pros: Zero install, works in any browser. Full Markdown including KaTeX math and Mermaid diagrams. Light and dark themes both export. No watermark on free accounts.
Cons: 1 MB input cap. One file at a time — see Batch convert Markdown to PDF for batch jobs.
When to use: 95% of one-off Markdown → PDF conversions.
Best for: Academic papers, custom LaTeX templates, citations and references, multi-format output (PDF + DOCX + EPUB from one source).
How:
brew install pandoc
brew install --cask basictex # or mactex (~5 GB)
pandoc input.md -o output.pdf
Time to first PDF: 30–90 minutes the first time (install Pandoc + LaTeX, hit template errors, fix them). 5 seconds afterward.
Pros: Battle-tested, scriptable, infinite templating via LaTeX. Handles citations natively (--bibliography). Runs offline. True book-quality typography.
Cons: LaTeX install is 3–5 GB. Default output is academic-paper aesthetic. Custom templates are hard. Code highlighting needs a separate --highlight-style flag and looks dated by web standards. Mermaid requires a filter plugin.
When to use: You're publishing a book, thesis, paper with bibliography, or you maintain three or more PDF templates that you want under version control.
Best for: People who write Markdown inside VSCode all day.
How: Install the "Markdown PDF" extension by yzane, right-click the file → Markdown PDF: Export (pdf).
Time to first PDF: 10 seconds the first time (the extension downloads Chromium silently, ~150 MB).
Pros: One click from where you're already writing. Configurable CSS via user settings. Decent default styling.
Cons: First export is slow because of the Chromium download. The PDF aesthetic is fine but not deeply customizable beyond CSS. KaTeX doesn't work out of the box — you need a separate Markdown+Math extension to render first. Mermaid blocks render as code, not diagrams.
When to use: You write five or more PDFs a week and your editor is VSCode.
Best for: Markdown that's already rendered in a browser (GitHub README, GitLab Wiki, rendered docs site).
How: ⌘+P or Ctrl+P → "Save as PDF".
Time to first PDF: 3 seconds.
Pros: Already there. No install. Works on any rendered HTML.
Cons: Page breaks split tables and code blocks unpredictably. Code highlighting often loses color in Firefox print. Default headers/footers are URL plus page numbers, which you usually have to disable manually. Doesn't render KaTeX or Mermaid unless the source page does.
When to use: You need a PDF right now of an already-rendered Markdown page and the rough edges don't matter.
Best for: Build pipelines, CI/CD, automated docs.
How:
npm install -g md-to-pdf
md-to-pdf input.md
Time to first PDF: 10 seconds (it bundles Puppeteer's Chromium, ~120 MB on first run).
Pros: Scriptable. YAML front-matter for per-document theming. Watch mode for live preview. Works offline once installed.
Cons: Node + Chromium dependency. Theme customization is YAML + CSS, not as expressive as Pandoc/LaTeX. Doesn't handle Mermaid out of the box — needs a markdown-it plugin.
When to use: Your docs site builds PDFs in CI; you want PDFs in version control alongside source.
Note: avoid the older markdown-pdf package (no hyphen) — it hasn't been updated since 2019 and has known security advisories. md-to-pdf is the maintained successor.
| Method | Install | First PDF | Highlights | Math | Mermaid | Best for |
|---|---|---|---|---|---|---|
/markdown-to-pdf | 0 MB | 5s | yes | yes (KaTeX) | yes | One-offs |
| Pandoc | 3–5 GB | 30–90 min | basic | yes (LaTeX) | filter | Books, papers |
| VSCode plugin | 150 MB | 10s | yes | needs ext | no | VSCode users |
| Browser print | 0 MB | 3s | varies | no | no | Already rendered |
md-to-pdf CLI | 120 MB | 10s | yes | needs config | needs plugin | CI/CD |
- Most readers →
/markdown-to-pdf. It is the answer for ~95% of cases. - Academics with citations → Pandoc.
- Daily VSCode users → the VSCode plugin.
- DocOps / CI builds →
md-to-pdfCLI. - GitHub README right now → browser print, accept the rough edges.
The temptation with Markdown → PDF tooling is to overengineer. If you're converting one document, install nothing. If you're converting a thousand documents, automate with the CLI. There is rarely a middle ground that justifies Pandoc for a non-academic.
Which method best preserves code highlighting?
The headless-Chromium options (/markdown-to-pdf, VSCode plugin, md-to-pdf CLI). They all render through real Chromium, so any highlight.js or Prism theme carries over. Pandoc's --highlight-style looks dated by web standards. Deeper dive: Markdown to PDF with code highlighting.
Can any of these batch convert multiple files?
The CLI does naturally (md-to-pdf chapter*.md). For the web tool, see Batch convert Markdown to PDF.
Why not markdown-pdf instead of md-to-pdf?
markdown-pdf (no hyphen) hasn't been updated since 2019 and has known security advisories. md-to-pdf is the maintained option.
Is there a Markdown-to-PDF API?
Yes — see our Markdown to Image API, which has a PDF output option for programmatic generation.
Which method handles Chinese / CJK fonts best?
/markdown-to-pdf and md-to-pdf use the host browser's font stack, so CJK works as long as the system has a CJK font installed. Pandoc with XeLaTeX needs explicit font config (mainfont:). VSCode plugin works fine with CJK out of the box.
Which one is cheapest to run at scale?
For 100+ PDFs/week, md-to-pdf in CI is essentially free (just compute). For occasional use, the browser-based path costs nothing. Pandoc is free but engineering time to maintain templates is the hidden cost.
The winner depends on your volume. One PDF → browser tool. 1000 PDFs → CLI in CI. Books with citations → Pandoc. Don't reach for the heavyweight option until you've felt the pain of the lightweight one.