How to Convert .md to PDF on Mac
5 methods — from one-click to command line
Why Convert Markdown to PDF?
Markdown files are great for writing and version control, but sometimes you need a PDF: to share a document with someone who doesn't have a Markdown viewer, to submit a report, or to print a spec. macOS makes this straightforward once you know where to look.
Method 1: MDViewer — Export as PDF (Easiest)
MDViewer has built-in PDF export — no print dialog required.
- Open the
.mdfile in MDViewer - Press ⌘⇧E (or choose File → Export as PDF…)
- Pick Portrait or Landscape orientation in the save dialog
- Choose a location and click Save
MDViewer uses smart pagination: tables, code blocks, images, and diagrams never break across pages. Headings stick with their content instead of sitting orphaned at the bottom of a page. Wide tables scale automatically to fit. The PDF always renders in light mode for clean, printable output.
Method 2: Print → Save as PDF
This works from any app that can render Markdown — including MDViewer.
- Open the
.mdfile in a Markdown viewer - Press ⌘P to open the Print dialog
- Click PDF in the bottom-left corner
- Choose Save as PDF
- Pick a filename and location, click Save
This preserves the rendered formatting — headings, bold, code blocks, lists — exactly as they appear on screen. The output quality depends on the app you're printing from, so using a dedicated Markdown viewer gives the best results.
Method 3: Pandoc (Command Line)
Pandoc is a powerful document converter that runs in the terminal. It produces high-quality PDFs with full control over styling.
- Install Pandoc:
brew install pandoc - Install a PDF engine (if needed):
brew install --cask basictex - Convert:
pandoc README.md -o README.pdf
Pandoc supports tables, footnotes, math, and custom templates. It is the best option for batch conversion or automated pipelines.
Method 4: VS Code Markdown PDF Extension
If you already use VS Code:
- Install the Markdown PDF extension
- Open the .md file
- Open the Command Palette (⌘⇧P)
- Type Markdown PDF: Export (pdf)
Quick and convenient if VS Code is already your editor, but it launches a full IDE just to convert a file.
Method 5: grip + Chrome (GitHub-Style PDF)
If you want the output to look exactly like GitHub renders your Markdown:
- Install grip:
pip install grip - Run:
grip README.md - Open
localhost:6419in Chrome - Press ⌘P → Save as PDF
Grip renders Markdown using GitHub's API, so the output matches GitHub's styling perfectly — ideal for READMEs and project documentation.
Which Method Should You Use?
| Method | Best for | Price | Setup |
|---|---|---|---|
| MDViewer export | Quick one-off conversion | Free | None — built in |
| Print → Save as PDF | Any app that renders Markdown | Free | None — built into macOS |
| Pandoc | Batch conversion, CI pipelines | Free | brew install pandoc |
| VS Code extension | Already using VS Code | Free | Install extension |
| grip + Chrome | GitHub-exact styling | Free | pip install grip |
For most people, MDViewer's built-in export is the fastest path: open the file, press ⌘⇧E, and you have a clean PDF with smart page breaks.
Tips for Better PDF Output
- Keep tables narrow — wide tables may get clipped in PDF. Use shorter column headers and abbreviations where possible.
- Use headings for structure — PDF readers use headings for bookmarks and navigation. A flat document with no headings produces a flat PDF.
- Check code blocks — long lines in fenced code blocks can overflow the page. Break lines at 80–100 characters for best results.
- Preview before exporting — open the file in MDViewer first to see exactly how tables, diagrams, and images will look in the final PDF.
- Mermaid diagrams — MDViewer renders Mermaid diagrams as SVGs in the PDF, so they stay sharp at any zoom level.
FAQ
Can I convert .md to PDF without installing anything?
Yes. Open the file in any Markdown viewer (or even a browser with a Markdown extension), then use ⌘P → Save as PDF. The macOS print dialog has a built-in PDF option.
Does MDViewer preserve code syntax highlighting in PDF?
Yes. Fenced code blocks export with full syntax highlighting for 180+ languages, matching what you see in the app.
Can I batch-convert multiple .md files to PDF?
Pandoc is the best tool for batch conversion. Use a shell loop: for f in *.md; do pandoc "$f" -o "${f%.md}.pdf"; done
What about converting Markdown to PDF on the command line?
Pandoc is the standard choice: pandoc file.md -o file.pdf. For custom styling, add --css=style.css or use a LaTeX template with --template.
Does the PDF include a table of contents?
With Pandoc, add --toc to auto-generate a table of contents. MDViewer's PDF export preserves heading structure, which PDF readers use for navigation bookmarks.
View Your Markdown Files with MDViewer
MDViewer is a free, native macOS app for reading and editing .md files. Open any Markdown file, see it rendered instantly, and export to PDF with ⌘⇧E when you need to share.
- Built-in PDF export — smart pagination, no broken tables or orphaned headings
- Renders GitHub Flavored Markdown — tables, task lists, code blocks
- Set as your default .md app — double-click in Finder to open
- Inline editing — fix and save without switching apps
- Launches instantly — native SwiftUI, no Electron overhead
Requires macOS 13.0 or later. Intel and Apple Silicon.