Skip to main content
pdfconversiontools

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.

By mdkit Team···6 min read
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
  • --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 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:

  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 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

SituationUse
One-off PDF, no installationBrowser tool
Book, thesis, academic paperPandoc + LaTeX
Client deliverable with brand CSSHTML/CSS engine with a versioned stylesheet
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
Browser-preview lookBrowser 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:

  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 the browser-based Markdown to PDF tool. For automation or configurable styling, evaluate Pandoc with a PDF engine that matches your typography and deployment needs.
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. Some HTML-based pipelines support CSS such as break-after: page, while LaTeX-based pipelines use other commands. Confirm raw HTML and print CSS support in your converter.
How do I add a cover page or table of contents?+
Pandoc supports a generated TOC and templates. Other tools vary; add a cover section and page-break rule only when the selected renderer documents support.
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