To convert Markdown to PDF, choose by situation. For a one-off document, paste it into a browser converter and download the file. For anything scripted or repeated, use Pandoc on the command line. If you already work in VS Code or Obsidian, their export works when it works — the catch with each is covered below. Every command on this page was run end to end to produce a PDF.
| Method | Best for |
|---|---|
| A browser converter | One document, converted by hand, with nothing to install. |
| Pandoc, on the command line | Anything automated, repeated, or part of a build. |
| Python | Generating PDFs from inside a Python program. |
| VS Code, with an extension | People who already write in VS Code, on a machine with open internet access. |
| Obsidian's built-in export | A note that only ever lives in Obsidian. |
| Printing a rendered preview | A quick copy when the formatting does not much matter. |
Paste the Markdown into a page, check the preview and download the PDF. No install, no account, and the rendering engine is the browser you already have open.
Tested: This site's own converter, which every other claim on this site is measured against.
The most capable option and the right one for a pipeline. Pandoc does not produce PDFs on its own: it hands the document to a PDF engine, and which engine you choose changes the result more than any flag does.
pandoc notes.md -o notes.pdf --pdf-engine=typstpandoc notes.md -o notes.pdf --pdf-engine=tectonic --toc -V geometry:margin=2cmTested: Run end to end on macOS with pandoc 3.12.1, Typst 0.15.1 and Tectonic 0.17.0. Both commands produced a PDF from the same test document; the long-line and Mermaid results above come from that run.
When the conversion is one step in a larger script, a library avoids shelling out. The markdown-pdf package has no system dependencies to install, which is the usual stumbling block with Python PDF libraries.
pip install markdown-pdffrom markdown_pdf import MarkdownPdf, Section
pdf = MarkdownPdf(toc_level=2)
with open("notes.md", encoding="utf-8") as f:
pdf.add_section(Section(f.read()))
pdf.save("notes.pdf")Tested: Run end to end with markdown-pdf 1.13.3 on Python 3.14, exactly as shown. The Mermaid and maths results above come from that run.
VS Code has no PDF export of its own, so this needs an extension. The popular ones produce print-accurate output by driving a headless copy of Chromium, which is also where they tend to fail.
Tested: Not run from here: an extension cannot be driven headlessly from this test setup. The steps describe the documented flow, and the Chromium behaviour is what these extensions state in their own setup notes.
Obsidian can export the open note to PDF directly. It is the quickest route for a note already in the vault, with the trade-off that the result goes through Obsidian's own renderer rather than one designed for paper.
Tested: Not run from here: Obsidian is a desktop app that cannot be driven headlessly from this setup. The steps describe its documented export flow.
Open the Markdown somewhere that renders it — a README on GitHub, or an editor's preview pane — then print the page and choose Save as PDF. It needs nothing at all, which is its whole appeal.
Tested: A browser's own print-to-PDF, which needs no install to check.
For a construct-by-construct breakdown of what survives conversion — measured by converting each one and inspecting the file — see which Markdown features survive PDF export. To convert a document now, there is a free markdown to pdf converter on this site, and a page specifically for turning a .md file to PDF.