How to Convert Markdown to PDF (5 Methods Compared)
Compare five Markdown-to-PDF workflows for quick exports, custom styling, editor use, documentation builds, and repeatable command-line automation.
On this page
Convert Markdown to PDF in a browser for one-off files, with Pandoc for configurable or automated output, through an editor for convenience, or from a documentation build for repeatable publishing.
Choose based on typography, page-break control, reproducibility, and installation constraints—not a universal ranking. For source-writing practices, see Markdown for technical writing.
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 performs conversion in the browser via html2pdf.js. Use it for a quick export, then inspect the downloaded file.
Pros:
- Zero setup
- Private (runs locally in your browser)
- Free
- Works on any OS
Cons:
- Limited styling options
- Not automatable
- Complex or long documents may require a more configurable pipeline
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 Pandoc and your chosen PDF engine using their current official instructions. LaTeX-based output requires a compatible TeX distribution; HTML/CSS-based engines have different dependencies.
Basic usage
pandoc input.md -o output.pdf
Done. That's the whole command.
With an HTML/CSS PDF engine
If you do not want LaTeX, Pandoc can work with supported engines such as WeasyPrint:
pandoc input.md -o output.pdf --pdf-engine=weasyprint
Install the engine from its current official documentation. wkhtmltopdf is archived and should not be the default for a new workflow.
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 deeper control, create a template compatible with the selected writer and PDF engine:
pandoc input.md -o output.pdf --template=my-template.tex
Pros:
- Industry-standard quality
- Suitable for long documents when the template and engine are configured appropriately
- Huge community, extensive docs
- Full LaTeX-level control
- Works in CI/CD pipelines
Cons:
- Some PDF engines have substantial installation requirements
- 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 static site generator plus a PDF export step can produce HTML and PDF from shared source.
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 workflows
Tools such as md-to-pdf can support scriptable Chromium-based output and per-document configuration. Check current maintenance, security, and installation instructions before adding a converter to CI.
An illustrative frontmatter configuration:
--- pdf_options: format: A4 margin: 20mm --- # Your content
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 | HTML/CSS engine with a versioned stylesheet |
| 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 |
| Browser-preview look | Browser print with versioned CSS |
Tips for better-looking PDFs
Regardless of which tool you pick, a few patterns make the output look more professional:
Use page breaks deliberately
If your HTML-based converter permits raw HTML and print CSS, a break can look like:
# Section 1 Content... <div style="page-break-after: always"></div> # Section 2 Content...
Some Pandoc LaTeX workflows accept \newpage; other writers and engines require different page-break rules.
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 whose sections are difficult to scan, a TOC can help. 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
Markdown Cheat Sheet: Syntax, Examples & GFM Reference
Copy Markdown syntax for headings, lists, links, images, code, tables, and task lists, with clear CommonMark and GitHub Flavored Markdown labels.
How to Convert HTML to Markdown: 5 Methods + Cleanup Tips
Convert HTML to Markdown with a browser tool, Turndown, Pandoc, or Python, then review tables, images, embeds, styles, and other lossy output.
Technical Writing in Markdown: Structure & Workflow
Structure tutorials, how-to guides, reference, and explanation in Markdown, with practical style, review, examples, linking, and maintenance workflows.