How to Convert Markdown to PDF: Browser, VS Code or Pandoc
Three ways to turn a Markdown (.md) file into a PDF — in your browser with nothing to install, in VS Code, or with Pandoc — and which one to pick.
Updated · 6 min read
Markdown is great for writing, but sooner or later someone asks for “a PDF”. Here are three ways to convert a .md file to PDF, from zero-install to fully scripted, and the settings that make the result look professional.
Option 1: Convert Markdown to PDF online (fastest, no install)
- Open the free online Markdown to PDF converter.
- Paste your Markdown, or drag your
.mdfile onto the page. - Click Style to choose a theme, paper size and margins.
- Click Download PDF and pick Save as PDF as the destination.
Everything happens on your device — the file isn’t uploaded — and the PDF contains real, selectable text with working links.
Best for: one-off documents, READMEs, notes, AI answers, resumes.
Option 2: VS Code with the Markdown PDF extension
If you already write in VS Code, the free Markdown PDF extension exports the file you have open:
- Install Markdown PDF (by yzane) from the Extensions view.
- Open your
.mdfile. - Press F1 (or Ctrl/⌘+Shift+P), type
exportand choose markdown-pdf: Export (pdf) — or right-click in the editor and pick the same command.
The first export downloads a copy of Chromium, so it takes a while; if Chrome is already installed, you can point the markdown-pdf.executablePath setting at it instead. Styling means writing your own CSS file (markdown-pdf.styles), and page numbers go in an HTML footer template (markdown-pdf.footerTemplate).
Best for: developers who export the same kind of document often. The full walkthrough, with settings for margins and page numbers, is in Markdown to PDF in VS Code.
Option 3: Pandoc on the command line
Pandoc converts Markdown to PDF through LaTeX:
pandoc notes.md -o notes.pdf --toc -V geometry:margin=2cm
--toc adds a table of contents and -V geometry:margin=2cm sets the margins. It produces beautiful typesetting, but you need a LaTeX distribution installed (several gigabytes), and HTML inside your Markdown or Mermaid diagrams won’t render without extra filters. If your text uses non-Latin scripts, switch to --pdf-engine=xelatex or lualatex, which work with your system’s Unicode fonts; to skip LaTeX entirely, Pandoc can also hand off to an HTML-based engine such as --pdf-engine=weasyprint (installed separately).
Best for: academic writing and automated build pipelines. See the Pandoc Markdown to PDF guide for engines, fonts and error fixes, or Markdown to PDF in Python if you want to script it.
Make the PDF look professional
Whichever method you choose, a few settings make a big difference:
| Setting | Why it matters |
|---|---|
| Page numbers | Readers can reference pages in feedback |
| Table of contents | Long documents become navigable |
| Margins of 18–25 mm | Comfortable reading and room for notes |
| Page breaks before major sections | Chapters start on a fresh page |
| Code blocks that don’t split | Snippets stay readable |
In the browser editor, all of these live under Style: turn on Header & footer for Page {page} of {pages}, Table of contents under Document, and Start a new page before → Each H1.
Common problems
- Images missing: relative paths like
./img/a.pngcan’t be resolved from pasted text. Use full URLs, import the README by link, or drag the image into the editor to embed it. - Equations show as code: make sure math is wrapped in
$…$or$$…$$(\(…\)and\[…\]work too). - Browser adds a URL and date to the pages: untick Headers and footers in the print dialog.
Try it on your own document
Free, private and right in your browser — no signup.