How to Convert Markdown to PDF: 5 Methods Compared (2026)
You finished a document in Markdown and now someone needs it as a PDF: a client, a compliance folder, a printer, or a reviewer who will not open a .md file. The task sounds trivial and usually is, right up to the moment the images vanish, the code blocks lose their colours, or the text in the finished PDF turns out not to be selectable. Searches for "convert markdown to pdf" run at 3,600 per month in the United States and have grown 125% in a year — 2,400 in July 2025 against 5,400 in June 2026 (DataForSEO Labs, July 2026) — which tracks with how much Markdown now comes out of AI coding agents.
This guide covers five ways to convert Markdown to PDF: a browser converter, Pandoc, a VS Code extension, hosted online services, and native macOS export. I build MacMD Viewer, a read-only macOS Markdown viewer at $19.99 one-time, so method five is mine — the other four are free and I use all of them. Working on a Mac specifically? The Markdown to PDF on Mac guide covers the macOS routes in more depth.
TL;DR: For one file with no install, use the free browser-based Markdown to PDF converter — it runs client-side, nothing is uploaded, but the text is not selectable. For searchable, typeset output or batch jobs, use Pandoc with a LaTeX engine. On macOS,
Shift+Cmd+Pin MacMD Viewer exports a themed PDF with Mermaid intact.
How Do You Convert Markdown to PDF?
Every method follows the same two moves: render the Markdown into formatted output, then write that output to PDF. Markdown is plain text, and nothing turns ## Heading into a heading on its own. The differences between tools come down to what survives the render — images, diagrams, syntax colours — and where the file is processed.
That second point decides more than people expect. A hosted converter sends your document to a server; a CLI tool, a native app and a client-side browser tool keep it on your machine. If the document is a client report or an unreleased spec, that distinction matters more than output quality.
Why Doesn't My Browser Convert a .md File?
Because no browser renders Markdown natively. Drag a .md file into Chrome or Safari and you get the raw source: literal asterisks, literal hash marks, no formatting. Pressing Cmd+P at that point produces a PDF of the source text. The browser can print a rendered page, but something else has to do the rendering first.
This trips people up constantly, and it is the reason "just open it in your browser" is bad advice. Any browser-based route needs a rendering step in front of it: a web converter, an editor extension, or an HTML file produced beforehand by a tool like Pandoc. Once the HTML exists, the browser's print dialog is a perfectly good PDF writer.
What Is the Fastest Way to Convert Markdown to PDF in a Browser?
Paste the Markdown into a converter that renders and exports in the same tab. The Markdown to PDF converter on this site does it in one step, with no account and no upload: it is built on html2pdf.js and runs entirely in your browser, producing A4 portrait pages with 16 mm margins. Mermaid diagrams render.
The honest limitation, and it is a real one: html2pdf.js draws the rendered page into an image and places that image into the PDF. Its own README states that the text is therefore "not selectable or searchable" and that this "causes large file sizes". For a signed-off report that someone will read and file, that is fine. For a document someone needs to search, quote from, or run through text extraction, pick a text-based exporter instead — Pandoc or the native macOS export below.
How Do You Convert Markdown to PDF with Pandoc?
Install Pandoc, install a LaTeX engine, then run one command. Pandoc is the reference tool for document conversion: more than 45,000 GitHub stars, GPL-2.0, continuously maintained since March 2010, with version 3.10.1 released on 22 July 2026 (GitHub API, 2026). Output quality is the best of any free option here.
brew install pandoc
brew install --cask basictex # or: brew install --cask tinytex
pandoc document.md -o document.pdf
The second line is the part most guides skip. Pandoc produces PDFs through LaTeX by default, so brew install pandoc alone leaves you with a command that fails on the first run. The Pandoc installation page recommends BasicTeX or TinyTeX on macOS rather than the full MacTeX distribution, purely for disk space. Alternative engines are selectable with --pdf-engine.
Once the engine is there, Pandoc gives you control nothing else on this list matches:
pandoc document.md -o document.pdf \
--pdf-engine=xelatex \
-V geometry:margin=1in \
-V mainfont="Helvetica Neue" \
--highlight-style=tango \
--toc
Mermaid needs the separate mermaid-filter plugin; Pandoc does not render fenced Mermaid blocks on its own.
Batch Converting a Whole Folder
A shell loop handles a directory, a repository, or a documentation tree with no quota and no upload:
for f in *.md; do
pandoc "$f" -o "${f%.md}.pdf" --pdf-engine=xelatex
done
In Node.js, md-to-pdf covers the same ground with glob patterns — npx md-to-pdf ./*.md. It is MIT-licensed at version 5.2.5 and was downloaded 142,529 times in the week of 18–24 July 2026 (npm registry downloads API, 2026). It renders through Marked, Puppeteer and highlight.js, and its dependency list and README document no Mermaid support, so diagram-heavy files are not its use case.
How Do You Export Markdown to PDF from VS Code?
Install the Markdown PDF extension, right-click the open .md file, choose Markdown PDF: Export (pdf). The PDF lands beside the original. If you already have the editor open, this is the shortest path in the list, and it exports to HTML, PNG and JPEG as well. A convertOnSave option regenerates the PDF on every save.
The yzane extension sits at version 2.1.0 with close to four million installations (Visual Studio Marketplace, July 2026). Worth correcting a claim that circulates widely, including in an older post on this site: the extension does render Mermaid, KaTeX and PlantUML in its PDF output today (extension README, July 2026). The real caveat is narrower and it applies to Mermaid alone — the Mermaid library is fetched from the URL in markdown-pdf.mermaidServer, which defaults to a CDN, so an export on a plane or behind a strict proxy comes back without the diagram. KaTeX, by contrast, renders in Node and needs no network at all.
Custom styling goes through markdown-pdf.styles, which takes your own CSS file.
VS Code, Cursor and JetBrains IDEs are where you write Markdown, and this extension is a good exporter. A viewer does a different job: reading and exporting a finished file without opening a project. They complement each other.
Are Online Markdown to PDF Converters Safe to Use?
They are safe in the ordinary sense and transparent about what they do, but most of them process your file on their servers, which is a different threat model from a local tool. PDF24 documents this openly: "The conversion of Markdown files is done on our servers", files sit on German servers and are "automatically deleted from the PDF24 server after one hour", with no registration and no stated limit (PDF24 Tools, July 2026).
CloudConvert's free tier allows 10 conversions per day on files up to 1 GB, with a five-minute processing ceiling and five concurrent jobs (CloudConvert Pricing, July 2026). Dillinger remains online as a live-preview editor that exports to HTML or PDF in a click, with no signup (dillinger.io, July 2026).
None of that is a criticism; PDF24 publishing its retention policy is more than many tools do. The point is to match the tool to the document. For a public README, upload away. For a client deliverable under NDA or anything holding customer data, use a converter that never transmits the file — which is why the converter on this site is client-side, a property you can confirm in the network tab rather than a promise in a privacy page.
Why Do My Images Disappear When I Convert Markdown to PDF?
Because relative image paths break the moment the renderer resolves them from a different working directory.  works in your editor because the editor knows where the file lives. Hand the same Markdown to a converter that runs from elsewhere, or paste the text into a web tool with no folder context at all, and the image reference resolves to nothing.
It is a well-worn complaint — "md to pdf with images" is a standing Google related search for this topic, and the question is one of the top-ranking Super User threads on it — and every method has its own fix.
Pandoc
Add the directories Pandoc should search:
pandoc document.md -o document.pdf --resource-path=.:images:assets
Run the command from the directory containing the Markdown file whenever you can. Pandoc resolves relative paths against the working directory, not against the input file's location, so cd first.
md-to-pdf
Set a baseURL so Puppeteer resolves relative references from the right root, or pass absolute paths.
Browser and hosted converters
Pasting Markdown into a web tool gives it no filesystem context whatsoever. Relative paths cannot work. Either point the images at public HTTPS URLs, or use a local tool for that document.
macOS apps
Sandboxed macOS applications need explicit permission for the folder holding the images, which is why MacMD Viewer ships a Grant Folder Access for Images… command in the File menu alongside the document's base URL. The export path carries that base URL into the offscreen render, so relative references are resolved against the document's own folder rather than against wherever the export runs from — the same mechanism --resource-path supplies to Pandoc.
The universal escape hatch, if you are debugging under time pressure: convert the image references to absolute paths, export, then revert. It is inelegant and it always works.
How Do You Convert Markdown to PDF on macOS?
The cross-platform methods all work on a Mac, and macOS adds native routes on top. In MacMD Viewer, File > Export as PDF… on Shift+Cmd+P writes the PDF directly. That shortcut is deliberately separate from Cmd+P: the system print panel's Save-as-PDF cannot carry the document theme, so the dedicated command exists to preserve it.
The dedicated export produces a continuous flow rather than paginated sheets, at a fixed 960 px width independent of your window size, so the same file always exports identically whether the window is narrow or full-screen. Mermaid diagrams stay as SVG, syntax highlighting survives, and the document theme carries over. MacMD Viewer is read-only by design: it reads and exports, it does not edit, which is why it sits next to your editor rather than replacing it.
For the full macOS walkthrough with every method side by side, read Markdown to PDF on Mac. If you are still at the stage of getting .md files to open at all, how to open a .md file covers that first.
Which Markdown to PDF Method Should You Choose?
Match the method to the constraint that actually binds you — privacy, searchable text, diagram support, or volume. Nothing here wins on every axis, and the free options cover most cases perfectly well.
| Method | Cost | Runs where | Selectable text | Mermaid | Batch |
|---|---|---|---|---|---|
| Browser converter (this site) | Free | Your browser | No (rasterised) | Yes | No |
| Pandoc | Free | Your machine | Yes | With mermaid-filter | Yes |
| VS Code + Markdown PDF | Free | Your machine | Yes | Yes (CDN required) | No |
| CloudConvert / PDF24 | Free tier | Their servers | Varies | Test your file | Varies |
| MacMD Viewer (macOS) | $19.99 one-time | Your Mac | Yes | Yes | No |
Quick decisions:
- One file, right now, nothing installed — the browser converter.
- Searchable, typeset, or hundreds of files — Pandoc with a LaTeX engine.
- Already in the editor — the VS Code extension, online.
- Confidential document — anything local: Pandoc, md-to-pdf, or a native viewer.
- Weekly exports on a Mac with diagrams and themes — MacMD Viewer.
For reference on the paid editor route: Typora costs $14.99 for up to three devices after a 15-day trial and exports PDFs with bookmarks (typora.io, July 2026). It is an editor, so it solves a broader problem than conversion alone.
What About the Other Direction and Other Formats?
Going backwards is harder, because PDF discards document structure — the PDF to Markdown converter guide covers what survives that trip. And if your recipient wants to edit rather than read, PDF is the wrong target: the Markdown to Word guide covers .docx, which is usually what people mean by "a document".
Frequently Asked Questions
How do I convert a Markdown file to PDF?
Render the Markdown first, then print or export the rendered output. Three fast routes: paste the file into a browser-based converter and download the PDF, run pandoc file.md -o file.pdf with a LaTeX engine installed, or right-click the file in VS Code and choose Markdown PDF: Export (pdf).
Can I convert Markdown to PDF without installing anything?
Yes. Browser-based converters do the whole job in a tab. The converter on this site runs client-side, so the file is never uploaded. CloudConvert allows 10 free conversions per day on files up to 1 GB, and PDF24 is unlimited and free, but both process the file on their own servers (CloudConvert Pricing and PDF24 Tools, July 2026).
Why are my images missing after converting Markdown to PDF?
Because the images are written as relative paths and the renderer resolved them from a different working directory. Pandoc takes --resource-path to add search directories, md-to-pdf takes a baseURL, and sandboxed macOS apps need explicit permission for the folder holding the images. Absolute paths sidestep the problem entirely.
Does Pandoc need LaTeX to produce a PDF?
By default, yes. Pandoc builds PDFs through LaTeX, so brew install pandoc on its own is not enough and the command fails without an engine. The Pandoc installation page recommends BasicTeX or TinyTeX on macOS over the full MacTeX distribution to save disk space. Other engines are selectable with --pdf-engine.
Does the VS Code Markdown PDF extension render Mermaid diagrams?
Yes. The yzane Markdown PDF extension renders Mermaid, KaTeX and PlantUML in its PDF output (extension README, July 2026). Mermaid is loaded from a CDN through the markdown-pdf.mermaidServer setting, so the diagram will not render if you export while offline.
Why is the text in my exported PDF not selectable?
The exporter rasterised the page. Converters built on html2pdf.js draw the rendered HTML into an image and place that image in the PDF, which the library's own README describes as making text neither selectable nor searchable, and producing large files. Use Pandoc or a text-based exporter when you need a searchable PDF.
What is the best way to convert many Markdown files at once?
A shell loop around Pandoc: for f in *.md; do pandoc "$f" -o "${f%.md}.pdf"; done. It runs locally, has no daily quota, and applies the same template to every file. md-to-pdf accepts glob patterns such as npx md-to-pdf ./*.md for the same job in Node.js.
How do I convert Markdown to PDF on a Mac specifically?
All the cross-platform methods work on macOS, plus native ones. MacMD Viewer has a dedicated File > Export as PDF command on Shift+Cmd+P that keeps the document theme, Mermaid diagrams and syntax highlighting. The Mac guide walks through each method with the exact keystrokes.
Content licensed under CC BY 4.0. Cite with attribution to MacMD Viewer.