How to Convert Markdown to PDF (5 Methods Compared)
Five ways to turn Markdown into a polished PDF — browser tools, Pandoc, VS Code, command-line utilities, and static site exports. Pros, cons, and which to pick.
Markdown is beautiful for writing and reading, but the real world still runs on PDFs. Resumes. Reports. Academic papers. Client deliverables. Proposals. You write in Markdown, you ship in PDF.
Here are the five best ways to make that conversion, ranked from easiest to most powerful.
1. Browser-based converters (easiest)
Best for: one-off documents, quick conversions, when you don't want to install anything.
Paste your Markdown into a web tool, see a preview, and download the PDF. That's the whole workflow.
Our Markdown to PDF tool runs entirely in your browser — nothing is uploaded, and the conversion happens client-side via html2pdf.js. Works for 95% of cases.
Pros:
- Zero setup
- Private (runs locally in your browser)
- Free
- Works on any OS
Cons:
- Limited styling options
- Not automatable
- Large documents (>50 pages) may slow the browser
How to use: paste your Markdown, click "Export PDF", done.
2. Pandoc (most powerful)
Best for: serious documents, automation, academic work, books.
Pandoc is the Swiss Army knife of document conversion. It reads and writes dozens of formats (Markdown, HTML, LaTeX, Word, EPUB, PDF, and many more) and handles extremely long documents gracefully.
Install
# macOS brew install pandoc # Ubuntu/Debian sudo apt install pandoc # Windows (via winget) winget install JohnMacFarlane.Pandoc
You'll also need a LaTeX distribution for PDF output (this is the part that intimidates people):
# macOS brew install --cask basictex # Ubuntu sudo apt install texlive-xetex # Windows # Install MiKTeX: https://miktex.org
Basic usage
pandoc input.md -o output.pdf
Done. That's the whole command.
With a custom PDF engine (simpler)
If you don't want LaTeX, use wkhtmltopdf or weasyprint:
brew install wkhtmltopdf # macOS pandoc input.md -o output.pdf --pdf-engine=wkhtmltopdf
With styling
pandoc input.md -o output.pdf \ --pdf-engine=xelatex \ --toc \ --variable geometry:margin=1in \ --variable mainfont="Inter" \ --variable fontsize=11pt
--tocgenerates a table of contents--variable geometry:margin=1insets page margins--variable mainfontsets the body font--variable fontsizesets font size
With a template
For total control, create a .tex template (or .html if using wkhtmltopdf) and pass it with --template:
pandoc input.md -o output.pdf --template=my-template.tex
Pros:
- Industry-standard quality
- Handles 500-page documents without sweat
- Huge community, extensive docs
- Full LaTeX-level control
- Works in CI/CD pipelines
Cons:
- LaTeX installation is ~2–4 GB
- Learning curve for templates
- Overkill for a one-page memo
3. VS Code extensions
Best for: when you're already writing in VS Code.
The popular extension is Markdown PDF:
- Install the extension.
- Open your Markdown file.
- Cmd/Ctrl + Shift + P → "Markdown PDF: Export (pdf)".
It uses a headless Chromium instance behind the scenes, which means the output looks like "print to PDF" from a browser — reliable, but styling options are limited to what the extension exposes (or what you inject via custom CSS in settings).
Pros:
- No context switch if you're in VS Code
- Supports custom CSS
- Fast for single files
Cons:
- Chromium dependency (large)
- Not automatable outside VS Code
- Styling is per-user (not portable to teammates)
4. Static site generators (best for repeating workflows)
Best for: documentation sites, books, report series.
If you maintain a collection of Markdown documents (a team wiki, a book, a documentation site), a static site generator plus a PDF export step gives you both HTML and PDF for free.
Options:
- Hugo — fast, with community PDF-export scripts.
- MkDocs + mkdocs-pdf-export-plugin — popular for dev docs.
- Docusaurus +
docusaurus-prince-pdf— for React-based doc sites. - mdBook — Rust-based, natural fit for technical books; has a print feature that exports to PDF via the browser.
Pros:
- Write once, ship to HTML and PDF
- Professional results with minimal styling effort
- Great for consistent branding across documents
Cons:
- Setup overhead
- Overkill for a single document
5. Command-line one-liners (for scripting)
Several CLI tools target "just convert this one file":
markdown-pdf (Node)
npm install -g markdown-pdf markdown-pdf input.md # outputs input.pdf
md-to-pdf (Node, faster)
npm install -g md-to-pdf md-to-pdf input.md
Supports front matter for per-document config:
--- pdf_options: format: A4 margin: 20mm --- # Your content
grip + browser print (for GitHub-style rendering)
pip install grip grip input.md --export input.html # then open input.html in a browser and print to PDF
This gives you pixel-perfect GitHub README rendering.
Pros:
- Scriptable, fits into CI/CD
- Fast for single files
- Some support custom CSS
Cons:
- Chromium/Node dependencies
- Styling varies by tool
Quick decision table
| Situation | Use |
|---|---|
| One-off PDF, no installation | Browser tool |
| Book, thesis, academic paper | Pandoc + LaTeX |
| Client deliverable with brand CSS | Pandoc + wkhtmltopdf + custom CSS |
| Already in VS Code | Markdown PDF extension |
| Repeating document series (reports, memos) | Static site generator + PDF plugin |
| Automated in CI (generate PDF on commit) | md-to-pdf or pandoc in GitHub Actions |
| GitHub README look | grip + print to PDF |
Tips for better-looking PDFs
Regardless of which tool you pick, a few patterns make the output look more professional:
Use page breaks deliberately
Add explicit breaks between major sections:
# Section 1 Content... <div style="page-break-after: always"></div> # Section 2 Content...
Pandoc users can use \newpage instead.
Add a cover page
Make your first H1 the title, then force a page break:
# Annual Report 2026 **Prepared by:** Team Name **Date:** March 2026 <div style="page-break-after: always"></div> ## Executive summary ...
Generate a table of contents
For documents over ~5 pages, a TOC helps. Our TOC Generator produces a Markdown TOC; Pandoc generates one automatically with --toc.
Choose a body font that prints well
- Serif (Georgia, Charter, EB Garamond): traditional, easy to read in long documents.
- Sans-serif (Inter, IBM Plex Sans, Source Sans): modern, great for reports and presentations.
- Monospace for code (JetBrains Mono, Fira Code): non-negotiable for readability.
Test with realistic content
A PDF with "Lorem ipsum" tells you nothing about how your real content flows. Always test with actual content — especially tables, which often overflow margins at default settings.
A practical workflow
For most people, the winning combo is:
- Write in Markdown using any editor (VS Code, Obsidian, our browser editor).
- Convert with our Markdown to PDF tool for one-off docs.
- Escalate to Pandoc the day you need pagination, a custom template, or CI automation.
You don't need all five tools. Pick the one that matches the job, and switch when the job changes.
Related reading
- How to convert HTML to Markdown — the reverse direction, with a similar tool breakdown.
- Markdown for technical writing — structure, style, and workflow tips.
- Best Markdown editors in 2026 — pick the right editor first.
Writing in Markdown and shipping in PDF is the path of least resistance for technical writing. Now you know every way to do it.
Frequently Asked Questions
What's the easiest way to convert Markdown to PDF?+
Can I use custom CSS to style the PDF?+
Do page breaks work in Markdown PDFs?+
How do I add a cover page or table of contents?+
Is there a free, open-source solution?+
Keep reading
The Complete Markdown Cheat Sheet (2026)
Every Markdown syntax you'll ever need, in one reference: headings, lists, tables, code blocks, links, images, task lists, and GitHub extensions. Print-friendly and bookmark-ready.
How to Convert HTML to Markdown (Clean, Lossless)
Convert HTML to Markdown cleanly — whether you're migrating a CMS, archiving web pages, or moving to a static site. Tools, gotchas, and how to handle messy input.
Using Markdown for Technical Writing
Why Markdown is the default format for technical writing in 2026, how to structure docs, and the patterns that keep large docs maintainable over time.