Printdown

How to convert Markdown to PDF: 4 free ways

By ·

Markdown is pleasant to write, but the person waiting for your document usually wants a PDF. There are plenty of ways to convert Markdown to PDF, and they differ more than the “md to pdf” label suggests: some need only a browser, others a full LaTeX installation; some render diagrams and math, others print them as code. This guide compares four free methods and gives exact steps for each.

Short answer: the fastest way is to open the Markdown to PDF editor, paste your Markdown or open the .md file, click Download PDF and choose Save as PDF in the print dialog. Nothing to install, and the PDF has real, selectable text. If you convert files in bulk or from scripts, or need a table of contents, use Pandoc or md-to-pdf; if you write in VS Code, an extension does it from the editor.

The four methods at a glance

Browser (Printdown)PandocVS Code + Markdown PDFmd-to-pdf
SetupNonePandoc plus LaTeX or another PDF engineVS Code and one extensionNode.js; downloads Chrome on install
Selectable textYes (Quick PDF: no)YesYesYes
Mermaid diagramsYesWith a filterYes, loaded from a CDNNot built in
MathYes (KaTeX)Yes (LaTeX)Yes (KaTeX)Not built in
Page numbers, table of contentsPage numbers only via browser headers; no TOCBothPage numbers by default; no TOCPage numbers via a footer template; no TOC
OfflineOnce the page has loadedYesYes, except Mermaid and PlantUMLYes, once installed
PrivacyRuns in your tab; nothing uploadedLocalLocal; PlantUML diagrams go to a serverLocal
Best forOne-off documents, styled PDFs, any computerLong or academic documents, automationPeople who already write in VS CodeScripts, CI and CSS styling

1. In the browser with Printdown

This is the method this site provides. Rendering and PDF creation happen in your browser tab, so it works on a Chromebook or a locked-down work laptop, and the document is never uploaded.

  1. Open the Markdown to PDF editor.
  2. Paste your Markdown into the left pane, or click Open .md file (.markdown and .txt work too). The preview on the right updates as you type.
  3. Click Style to choose one of six themes, the text, heading and link colors, a font size from 9 to 14 pt, A4 or Letter, and Narrow, Normal or Wide margins.
  4. Click Download PDF. Your browser’s print dialog opens.
  5. Choose Save as PDF as the destination (Firefox calls it Save to PDF), turn off Headers and footers and save. The suggested file name comes from the first heading.

The editor handles GitHub-style tables, task lists, footnotes and highlighted code, plus Mermaid diagrams and LaTeX math. To skip the dialog, More → Quick PDF (image) downloads a file in one click, but every page is a picture: the text can’t be selected or searched.

The limits, honestly: there is no page-number or table-of-contents option (the browser’s headers and footers add page numbers, but also the date, title and page address); pages are portrait only; a web page can’t read images from your disk, so relative image paths must become URLs; and each export goes through the print dialog, one document at a time.

2. Pandoc (command line)

Pandoc is a free, open-source document converter. It is the most capable option here and the one with the most moving parts.

Install it

  • Windows: winget install --source winget --exact --id JohnMacFarlane.Pandoc, or the installer from the download page.
  • macOS: brew install pandoc.
  • Linux: your package manager (check that its version isn’t outdated) or the .deb or tarball from the download page.

By default Pandoc makes PDFs through LaTeX, which is a separate install. The installation page recommends MiKTeX on Windows, BasicTeX or TinyTeX on macOS (a full MacTeX takes about 4 GB) and TeX Live on Linux (sudo apt-get install texlive on Debian and Ubuntu).

Convert

pandoc notes.md -o notes.pdf

The .pdf extension is enough: Pandoc converts to LaTeX and runs pdflatex. Pick another engine with --pdf-engine; the manual lists pdflatex, lualatex, xelatex, latexmk, tectonic, wkhtmltopdf, weasyprint, pagedjs-cli, prince, context, groff, pdfroff and typst, each installed separately.

pandoc notes.md --pdf-engine=xelatex -V mainfont="Noto Serif" -o notes.pdf
pandoc notes.md --pdf-engine=weasyprint --css=print.css -o notes.pdf
pandoc notes.md --pdf-engine=typst -o notes.pdf

xelatex and lualatex handle Unicode and any installed font; WeasyPrint goes through HTML, so you style it with CSS; Typst is a newer typesetting system that installs as a single program.

Useful options

pandoc report.md -o report.pdf --toc -N -V geometry:margin=2cm -V papersize=a4
  • --toc adds a table of contents and -N numbers the sections.
  • -V geometry:margin=2cm sets the margins and -V papersize=a4 (or letter) the paper size, with the LaTeX engines.
  • A YAML block at the top of the file with title, author and date becomes the title block.
  • \newpage on its own line forces a page break with LaTeX engines.

Common errors

  • pdflatex not found: LaTeX isn’t installed or isn’t on your PATH. Install it and open a new terminal, or choose another --pdf-engine.
  • LaTeX Error: File `….sty' not found: a minimal distribution lacks a package. Add it with tlmgr install and the package name (TeX Live, BasicTeX, TinyTeX); MiKTeX can install missing packages on the fly.
  • Unicode character … not set up for use with LaTeX: emoji, CJK text or rare symbols with pdflatex. Switch to xelatex or lualatex and a font that contains those characters.
  • Images not found: relative paths are resolved from the folder you run the command in, not the file’s folder. Run Pandoc from there or add --resource-path.
  • Diagrams or HTML missing: Mermaid blocks print as code unless you add a filter, and raw HTML is dropped on the way through LaTeX.

3. VS Code with the Markdown PDF extension

VS Code’s built-in Markdown preview (Ctrl+Shift+V) has no export or print command. The usual answer is the Markdown PDF extension by yzane, which prints the file with a Chromium-based browser and saves the PDF next to it.

  1. Open the Extensions view (Ctrl+Shift+X), search for Markdown PDF and install the one published by yzane.
  2. Open your .md file.
  3. Press F1 or Ctrl+Shift+P (Cmd+Shift+P on a Mac), type export and choose Markdown PDF: Export (pdf). The same commands appear when you right-click in the editor.

It uses an installed Chrome or Edge, or downloads Chromium on first use. By default the header shows the file name and date and the footer shows page / total. Change that and more in settings.json:

"markdown-pdf.format": "Letter",
"markdown-pdf.margin.top": "2cm",
"markdown-pdf.displayHeaderFooter": false,
"markdown-pdf.styles": ["print.css"],
"markdown-pdf.convertOnSave": true

Convert-on-save takes effect after restarting VS Code. The extension renders task lists, KaTeX math, Mermaid (the library is loaded from a CDN, so diagrams need a connection) and PlantUML, which is sent to a PlantUML server, plantuml.com by default. Use <div class="page"></div> for a page break; the README lists every option.

4. md-to-pdf (Node.js)

md-to-pdf is a small command-line tool: it turns Markdown into HTML with Marked, highlights code with highlight.js and prints the page with Puppeteer (headless Chromium). With Node.js installed:

npx md-to-pdf notes.md

That writes notes.pdf next to the source. To keep the command, install it with npm i -g md-to-pdf. The first install is slow because Puppeteer downloads its own Chrome.

Styling is plain CSS: --stylesheet print.css replaces the built-in stylesheet, --css adds rules inline and --highlight-style picks a highlight.js theme. Options can also live in front matter, which saves you from quoting JSON in the shell:

---
stylesheet: print.css
pdf_options:
  format: Letter
  margin: 20mm
  printBackground: true
---

# Quarterly report

It converts several files at once (md-to-pdf docs/*.md), has a --watch mode and accepts Puppeteer’s headerTemplate and footerTemplate for page numbers. Page breaks use <div class="page-break"></div>; math and Mermaid aren’t built in. Its README notes that it serves the current folder on a local web server, reachable from your network while it runs, so don’t start it from your home folder; files outside the current folder need --basedir.

Which one should you use?

  • One document, now, on any computer: the browser. Themes give a designed look without writing CSS.
  • A thesis, paper or book with math, citations, numbered sections and a table of contents: Pandoc with LaTeX or Typst.
  • Documentation you edit in VS Code: the Markdown PDF extension, with convert-on-save if you re-export often.
  • Batch jobs, build scripts or CI: md-to-pdf, or Pandoc if you already have an engine set up.
  • Page numbers are mandatory: Pandoc, the VS Code extension or md-to-pdf’s footer template.

For specific documents, see the guides to a report or proposal, a resume and a GitHub README.

Tips for every method

  • Images. Relative paths resolve from a different place in each tool: Pandoc from the folder you run it in, md-to-pdf from the folder it serves, the VS Code extension from the file’s folder, and a web page not at all. Absolute https:// URLs work everywhere when you’re online.
  • Page breaks. Printdown accepts <!-- pagebreak --> or \newpage; Pandoc with LaTeX, \newpage; the VS Code extension, <div class="page"></div>; md-to-pdf, <div class="page-break"></div>.
  • Code. Put the language after the opening fence (```python) so every tool can highlight it. Browser-based tools wrap long lines; Pandoc’s LaTeX output doesn’t, so long lines can run past the margin.
  • Fonts. The browser-based tools take fonts from themes or CSS; with Pandoc, use xelatex or lualatex and -V mainfont="…".
  • Front matter. The YAML block at the top is metadata for Pandoc and settings for md-to-pdf and the VS Code extension, but Printdown prints it as text, so delete it there.

Troubleshooting

  • The text can’t be selected. You used an image-based export such as Quick PDF. Use Download PDF and Save as PDF.
  • Mermaid or math appears as code. The tool doesn’t render it (Pandoc without a filter, md-to-pdf). In Printdown, red text in place of a diagram means it has a syntax error.
  • A table runs off the page. Lower the font size and margins, or split the table (see Markdown tables). Landscape helps where available: -V geometry:landscape in Pandoc, "markdown-pdf.orientation": "landscape" in VS Code, landscape: true under pdf_options in md-to-pdf. Printdown is portrait only.

Quick answers

Can I convert Markdown to PDF without installing anything?

Yes. The browser method needs only a modern browser, and the conversion runs on your device.

Will the text in the PDF be selectable?

With all four methods, yes: the PDF contains real text that can be searched and copied. The one exception is Quick PDF, which saves pages as images.

Is it safe for confidential documents?

All four convert on your own computer and don’t upload your text. Two things to watch: images you link to are fetched from their servers, and the VS Code extension sends PlantUML diagrams to a PlantUML server.

Which one looks best?

LaTeX, through Pandoc, has the most refined line breaking and math typesetting. The browser-based tools are easier to restyle with themes or CSS. New to the syntax? Start with the Markdown guide.

More guides