5 Ways to Convert Markdown to PDF Compared (Pandoc, VSCode, Online Tools)
For a one-off document, the browser-based /markdown-to-pdf has the least setup. Pandoc is stronger for citations and publishing pipelines; VS Code and CLI options fit editor-centric or automated work. The right choice depends on document features, repeatability, and local-control requirements.
This comparison uses current documented capabilities rather than fixed stopwatch or download-size claims, because setup time and bundled browser size vary by operating system and release.
Best for: One-off conversion, code highlighting, math, diagrams, no install.
How: Open /markdown-to-pdf, paste, click PDF.
Setup and first run: Varies by operating system, installed PDF engine, cache state, and document complexity; test on your own environment.
Pros: No local installation and works in a browser. It renders code highlighting, KaTeX, Mermaid, tables, images, and task lists. Free output is watermarked; signed-in free users currently receive five watermark-free exports in total.
Cons: 1 MB input cap. One file at a time — see Batch convert Markdown to PDF for batch jobs.
When to use: most 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 (platform-dependent)
pandoc input.md -o output.pdf
Setup and first run: Varies by operating system, installed PDF engine, cache state, and document complexity; test on your own environment.
Pros: Battle-tested, scriptable, infinite templating via LaTeX. Handles citations natively (--bibliography). Runs offline. True book-quality typography.
Cons: LaTeX install is platform-dependent. Default output is academic-paper aesthetic. Custom templates are hard. Code highlighting needs a separate --syntax-highlighting 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).
Setup and first run: Varies by operating system, installed PDF engine, cache state, and document complexity; test on your own environment.
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".
Setup and first run: Varies by operating system, installed PDF engine, cache state, and document complexity; test on your own environment.
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
Setup and first run: Varies by operating system, installed PDF engine, cache state, and document complexity; test on your own environment.
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 | None | Browser request | yes | yes (KaTeX) | yes | One-offs |
| Pandoc | Pandoc + PDF engine | Setup-dependent | yes | yes | filter | Books, papers |
| VS Code Markdown PDF | Extension + renderer | Setup-dependent | yes | extension-dependent | no | Editor users |
| Browser print | None | Browser request | varies | source-dependent | source-dependent | Rendered pages |
md-to-pdf CLI | Node.js + browser runtime | Setup-dependent | yes | configurable | plugin | CI/CD |
- Most readers →
/markdown-to-pdf. It is the answer for most 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 --syntax-highlighting 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.
Which method handles Chinese / CJK fonts best?
The hosted /markdown-to-pdf renderer uses its server-side font environment. Local Chromium tools use fonts available in their runtime, while Pandoc with XeLaTeX normally needs an explicit CJK font such as mainfont:. Always test the exact characters you publish.
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.
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.