How to Convert Markdown to PDF

February 9, 2026 · 7 min read

Markdown is great for writing, but when it's time to share a polished document — a report, a proposal, a resume, or a handout — you usually need a PDF. PDFs look the same on every device, can't be accidentally edited, and are the universal format for professional documents.

This guide covers every practical method for converting Markdown to PDF, from one-click browser tools to powerful command-line utilities.

Method 1: Online Converters (Easiest)

The fastest way to convert Markdown to PDF is with a browser-based tool. No installation, no configuration — paste or type your Markdown and click export.

MarkdownFTW is one such tool. It gives you a live preview of your Markdown and lets you export directly to PDF with one click. Everything runs in your browser — your content is never uploaded to a server, which is important if you're working with sensitive documents.

How to do it:

  1. Open MarkdownFTW in your browser.
  2. Write or paste your Markdown in the editor pane.
  3. Check the live preview to make sure everything looks right.
  4. Click the PDF export button.
  5. Your browser downloads the PDF instantly.

This method is ideal for quick conversions — notes, meeting agendas, simple documents. If you need precise control over page margins, headers/footers, or page breaks, read on for more advanced methods.

Method 2: Pandoc (Most Powerful)

Pandoc is the Swiss Army knife of document conversion. It's a free, open-source command-line tool that converts between dozens of formats, and it produces some of the best-looking PDFs from Markdown.

Installation

# macOS
brew install pandoc

# Ubuntu/Debian
sudo apt install pandoc

# Windows (with chocolatey)
choco install pandoc

Pandoc uses LaTeX to generate PDFs by default, so you'll also need a LaTeX distribution. The easiest option is tinytext or the full TeX Live:

# macOS
brew install --cask mactex-no-gui

# Ubuntu/Debian
sudo apt install texlive-xetex

# Or use Pandoc's built-in option (no LaTeX needed):
pandoc document.md -o output.pdf --pdf-engine=weasyprint

Basic Conversion

pandoc document.md -o output.pdf

That's it. One command. Pandoc reads the Markdown, processes it, and generates a PDF.

Customizing the Output

Pandoc's real power is customization. Here are some useful flags:

# Custom margins
pandoc doc.md -o out.pdf -V geometry:margin=1in

# Table of contents
pandoc doc.md -o out.pdf --toc

# Custom font (with XeLaTeX)
pandoc doc.md -o out.pdf --pdf-engine=xelatex \
  -V mainfont="Helvetica" -V fontsize=12pt

# Syntax-highlighted code blocks
pandoc doc.md -o out.pdf --highlight-style=tango

# Combine multiple files
pandoc chapter1.md chapter2.md chapter3.md -o book.pdf

You can even create custom LaTeX templates for consistent branding across all your documents. Pandoc is the best choice for automated pipelines, academic papers, and anyone who wants full control over the output.

Method 3: VS Code Extensions

If you write Markdown in Visual Studio Code, several extensions can export directly to PDF without leaving your editor:

  • Markdown PDF — The most popular option. Right-click any .md file and select "Markdown PDF: Export (pdf)". It uses Chromium under the hood to render the HTML and print it to PDF.
  • Markdown Preview Enhanced — A feature-rich preview extension that includes PDF export via Puppeteer or Prince.

These are convenient if you're already in VS Code, though they offer less customization than Pandoc.

Method 4: Node.js / JavaScript

For developers who want to integrate Markdown-to-PDF conversion into their apps or build scripts, there are excellent JavaScript libraries:

// Using md-to-pdf (Node.js)
import { mdToPdf } from 'md-to-pdf';

const pdf = await mdToPdf({ path: 'document.md' });
fs.writeFileSync('output.pdf', pdf.content);

Other options include:

  • md-to-pdf — Simple, opinionated, uses Puppeteer. Great for CI/CD pipelines.
  • markdown-pdf — Older but battle-tested. Uses PhantomJS.
  • Puppeteer + marked — Maximum flexibility. Parse Markdown to HTML with marked, then use Puppeteer to print to PDF.

Method 5: Print from Browser

A surprisingly effective low-tech method: render your Markdown as HTML in any viewer, then use your browser's "Print to PDF" function (Ctrl/Cmd + P → Save as PDF). This works with any Markdown preview tool, including GitHub's file viewer.

The result depends on the CSS styling of the preview. Tools like MarkdownFTW with clean typography produce better print results than minimal viewers.

Tips for Better PDFs

Regardless of which method you use, these tips help produce cleaner results:

  • Use proper heading hierarchy. Start with # H1 for the title, then ## H2 for major sections. Don't skip levels. This creates a clean table of contents.
  • Keep images reasonable. Embed images at appropriate sizes. Giant images will overflow pages in PDF output.
  • Use horizontal rules for page breaks. In many converters, --- translates to a page break in the PDF, or you can use \newpage in Pandoc with LaTeX.
  • Test code blocks. Long code lines may get cut off in PDFs. Use line wrapping or keep code examples concise.
  • Add YAML front matter. Pandoc and many tools read metadata from front matter for title pages:
---
title: "Quarterly Report"
author: "Jane Doe"
date: "February 2026"
---

# Introduction
Your content starts here...

Which Method Should You Use?

  • Quick, one-off conversions MarkdownFTW or any online tool
  • Regular document production → Pandoc with a custom template
  • Already in VS Code → Markdown PDF extension
  • Automated pipelines / CI → Pandoc or md-to-pdf in a build script
  • Academic papers → Pandoc with LaTeX for the best typography

For most people, starting with a browser-based tool and graduating to Pandoc when you need more control is the ideal path. You don't need to over-engineer a simple conversion.

Try it yourself

Paste your Markdown into MarkdownFTW and export to PDF in one click — free and private.

Open the Editor →