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.

  1. Open the .md file in MDViewer
  2. Press ⌘⇧E (or choose File → Export as PDF…)
  3. Pick Portrait or Landscape orientation in the save dialog
  4. 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.

  1. Open the .md file in a Markdown viewer
  2. Press ⌘P to open the Print dialog
  3. Click PDF in the bottom-left corner
  4. Choose Save as PDF
  5. 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.

  1. Install Pandoc: brew install pandoc
  2. Install a PDF engine (if needed): brew install --cask basictex
  3. 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:

  1. Install the Markdown PDF extension
  2. Open the .md file
  3. Open the Command Palette (⌘⇧P)
  4. 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:

  1. Install grip: pip install grip
  2. Run: grip README.md
  3. Open localhost:6419 in Chrome
  4. Press ⌘PSave 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?

MethodBest forPriceSetup
MDViewer exportQuick one-off conversionFreeNone — built in
Print → Save as PDFAny app that renders MarkdownFreeNone — built into macOS
PandocBatch conversion, CI pipelinesFreebrew install pandoc
VS Code extensionAlready using VS CodeFreeInstall extension
grip + ChromeGitHub-exact stylingFreepip 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
Download MDViewer for Free

Requires macOS 13.0 or later. Intel and Apple Silicon.