pdfconversiontools

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.

By mdkit Team··7 min read

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
  • --toc generates a table of contents
  • --variable geometry:margin=1in sets page margins
  • --variable mainfont sets the body font
  • --variable fontsize sets 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:

  1. Install the extension.
  2. Open your Markdown file.
  3. 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

SituationUse
One-off PDF, no installationBrowser tool
Book, thesis, academic paperPandoc + LaTeX
Client deliverable with brand CSSPandoc + wkhtmltopdf + custom CSS
Already in VS CodeMarkdown 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 lookgrip + 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:

  1. Write in Markdown using any editor (VS Code, Obsidian, our browser editor).
  2. Convert with our Markdown to PDF tool for one-off docs.
  3. 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.

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?+
For one-off conversions, use our browser-based Markdown to PDF tool — paste, preview, and download, all without installing anything. For automation or advanced styling, Pandoc is the industry standard.
Can I use custom CSS to style the PDF?+
Yes, depending on the tool. Our browser tool applies a clean default stylesheet. Pandoc accepts --css for HTML-based PDFs. VS Code extensions like Markdown PDF have style configuration. For full control, generate HTML with a Markdown tool, style it with CSS, and print to PDF from the browser.
Do page breaks work in Markdown PDFs?+
Markdown has no native page-break syntax, but HTML does. Insert <div style='page-break-after: always'></div> in your Markdown at the point you want a new page. Most Markdown-to-PDF pipelines will respect it.
How do I add a cover page or table of contents?+
Pandoc supports both via --toc and templates. For simpler tools, write a cover page as the first section with a forced page break after, and generate your TOC separately using our TOC generator.
Is there a free, open-source solution?+
Yes. Pandoc is free, open-source, and available on every platform. Our browser-based tool is free too. Many VS Code extensions and GitHub Actions also do it free of charge.

Keep reading