Markdown to PDF: 5 Free Ways That Keep Your Formatting

Convert Markdown to PDF with VS Code, Pandoc, your browser, or free online tools — with the exact settings that keep code blocks and tables intact.

By PeacefulPDF Team

Markdown is wonderful right up until someone asks for the file "as a PDF, please." There's no Save As PDF button in a .md file, and the first few converters you try will mangle your code blocks, drop your tables, or slap a watermark across the page. After converting a lot of README files, meeting notes, and documentation over the years, these are the five methods I actually use, roughly in order of how often I reach for them.

1. VS Code (probably already on your machine)

If you write Markdown, odds are you write it in VS Code. Install the free Markdown PDF extension by yzane, open your file, then run Markdown PDF: Export (pdf) from the command palette (Ctrl + Shift + P). Done. Code blocks keep their syntax highlighting, tables render as tables, and the default stylesheet looks clean enough to send to anyone.

The one gotcha: the extension downloads a headless Chromium the first time it runs, so the first export takes a minute. Every export after that is instant.

2. Print from anywhere Markdown renders

This one feels like cheating but works surprisingly well: open your Markdown anywhere that renders it — GitHub, GitLab, Obsidian, a preview pane — and print the page to PDF (Ctrl + P, destination "Save as PDF"). On Windows, that's the same trick as Microsoft Print to PDF.

Two tips that fix 90% of ugly results: turn off headers and footers in the print dialog (otherwise the URL and date get stamped on every page), and set margins to "Default" rather than "None" so text doesn't run to the paper edge. GitHub's rendered view prints particularly nicely because its stylesheet was designed for readability.

3. Pandoc (best output, steepest setup)

Pandoc is the standard converter for people who do this daily. Once installed, the conversion is one line:

pandoc notes.md -o notes.pdf

By default Pandoc goes through LaTeX, which produces beautiful, book-quality output — but it means installing a LaTeX distribution, which is a multi-gigabyte commitment. The lighter path is pandoc notes.md -o notes.pdf --pdf-engine=typst with the much smaller Typst engine, or going through HTML with --pdf-engine=weasyprint. If you only convert a file occasionally, methods 1 and 2 will get you there with far less setup.

4. md-to-pdf for scripting

If you need conversion inside a build process — docs generated on every release, say — the md-to-pdf npm package wraps headless Chrome and accepts custom CSS: npx md-to-pdf README.md. It respects your stylesheet, so branded output is easy. Overkill for one-off files.

5. Online converters (read this first)

Plenty of websites convert Markdown to PDF. The catch nobody mentions: most of them upload your file to a server to do it. For a public README that's fine. For meeting notes, internal docs, or anything with names and numbers in it, I'd think twice — here's what actually happens when you upload a document to a converter site. Methods 1–4 all run entirely on your own machine, which is the quiet advantage of doing it locally.

After the conversion

Whichever route you take, the finishing touches are easier on the PDF side. Need to combine several converted files into one document? Use our merge tool. Chrome's print output can also run large if your Markdown embeds images — our compressor shrinks those down. Both run in your browser, so the files never leave your computer.

And if you ever need to go the other way — pull Markdown back out of a PDF someone sent you — we've covered that in our PDF to Markdown guide.

Which one should you pick?

  • One file, right now: print to PDF from wherever it renders.
  • You live in VS Code: the Markdown PDF extension.
  • Beautiful output, often: Pandoc.
  • Automated pipeline: md-to-pdf.
  • Sensitive content: any of the local methods — skip the upload sites.