How to Convert Markdown to PDF

Three ways to turn a .md file into a clean, shareable PDF — from a free browser tool to command-line options.

Why convert markdown to PDF?

Markdown is great for writing — it's plain text, version-controllable, and renders everywhere. But when you need to share a document with someone outside a technical context, or attach it to an email, PDF is the universal format. PDF preserves your formatting exactly, works offline, and doesn't require the reader to have any markdown renderer installed.

  • Share technical documentation with non-technical stakeholders
  • Submit reports, specs, or proposals in a printable format
  • Archive AI context files and README files for offline reference
  • Create shareable project documentation from your markdown notes

3 ways to convert markdown to PDF

Choose based on your needs — no-install browser tools, browser print, or command line.

🌐

Method 1: Use a free online converter

Recommended — no install needed

The fastest way. Open markdownutils.com/pdf, paste your markdown, choose a theme, and export. Everything runs in your browser — nothing is uploaded to a server.

Step by step

1

Open the tool

2

Add your markdown

Paste your markdown directly into the editor, or click Upload in the toolbar to load a .md file from your computer.
3

Choose a theme and settings

Pick from Light, Dark, Sepia, Minimal, or Ocean themes. Adjust font size, line spacing, margins, and font family to match your document's needs.
4

Export

Click Export PDF. Your browser's print dialog opens automatically. Select Save as PDF as the destination and click Save.
Tip: In the print dialog, enable "Background graphics" to preserve colored themes and code block backgrounds.
🖨️

Method 2: Browser print (any markdown renderer)

If you're already viewing rendered markdown — on GitHub, VS Code preview, or any other renderer — you can print it to PDF using your browser's built-in print function.

  1. Open the rendered markdown in your browser
  2. Press Ctrl+P (Windows/Linux) or Cmd+P (Mac)
  3. Set destination to Save as PDF
  4. Click Save

Quality varies depending on the renderer's CSS. GitHub's markdown renderer produces clean PDFs. Raw .md files opened directly in a browser won't render — you need a viewer first.

⚙️

Method 3: Command line with Pandoc

Pandoc is the most powerful option — a universal document converter that can turn markdown into PDF, Word, HTML, ePub, and more. Requires installation and a LaTeX engine for PDF output.

Install Pandoc:

# macOS (Homebrew)
brew install pandoc
brew install --cask basictex

# Ubuntu / Debian
sudo apt-get install pandoc texlive

# Windows (Chocolatey)
choco install pandoc miktex

Convert a markdown file:

# Basic conversion
pandoc README.md -o output.pdf

# With custom margins and font size
pandoc README.md -o output.pdf \
  -V geometry:margin=1in \
  -V fontsize=12pt

# With a custom template
pandoc README.md -o output.pdf --template=mytemplate.tex

Pandoc gives you full control over the output, but requires a working LaTeX installation which can be complex to set up. For most use cases, the browser-based approach is faster.

Themes & typography options

Markdown Utils supports 5 themes, 13 font families, and 3 style controls — all reflected live in the preview before you export.

Themes

Aa

Light

Clean white background, slate headings, blue links and blockquotes. The default — works for any document type and prints cleanly on standard paper.

Best for: Reports, documentation, general use

Aa

Dark

Near-black (#0a0a0a) background with slate body text, indigo accents, and cyan inline code. Ideal for code-heavy documents or sharing in developer contexts.

Best for: Technical docs, code references, developer audiences

Aa

Sepia

Warm cream background (#f5f3ed), Georgia serif body font, warm brown borders. Code blocks use a high-contrast black-on-white style. Great for long-form reading.

Best for: Long documents, essays, documentation meant to be read carefully

Aa

Minimal

Pure black on white with no decorative color — borders, blockquotes, and table headers all in black. Helvetica Neue body font. Closest to a printed book or academic paper.

Best for: Academic papers, formal reports, print-first documents

Aa

Ocean

Deep navy background (#0d1b2a), muted blue body text, teal accents and links. A dark theme with a distinct nautical palette — more atmosphere than the Dark theme.

Best for: Portfolio documents, creative technical writing, developer showcases

Syntax highlighting

Each theme ships with a matched highlight.js code theme — syntax colours are chosen to complement the document palette rather than clash with it. Highlighting is applied in both the live preview and the exported PDF.

ThemeCode highlight theme
LightGitHub
DarkGitHub Dark
Sepiaa11y-light
MinimalStack Overflow Light
OceanNord

Specify the language after the opening triple-backtick (e.g. ```python) to activate highlighting.

Font families

Nine fonts covering the main use cases — system fonts load instantly, Google Fonts load on-demand and embed in the PDF.

FontTypeBest for
System SansSans-serif · SystemDefault — native OS font, no loading delay, crisp at any size
InterSans-serif · GoogleTechnical docs, SaaS documentation, screen-first content
RobotoSans-serif · GoogleGeneral documents, clean and neutral
Open SansSans-serif · GoogleDense body-heavy content, accessible writing
LatoSans-serif · GoogleBusiness reports, professional presentations
GeorgiaSerif · SystemLong-form reading, essays, print-first documents
MerriweatherSerif · GoogleLong technical writing, screen-first long-form content
Playfair DisplaySerif · GoogleProposals, covers, portfolio documents
JetBrains MonoMonospace · GoogleDeveloper docs, code-first documents

Style controls

Font size

Range: 10px – 20px

Default: 14px

Controls the base font size for body text. Headings scale proportionally. Use 12–13px for dense technical documents, 15–16px for comfortable reading, 18–20px for presentations.

Line spacing

Range: 1.2 – 2.5

Default: 1.75

The line-height multiplier. 1.4–1.6 is tight and compact, 1.7–1.9 is comfortable for reading, 2.0+ is airy and open. The default (1.75) balances density with readability.

Margins

Range: None / Narrow / Normal / Wide

Default: Normal

Controls the padding around the document content. Normal (50px top/bottom, 60px sides) suits most documents. Narrow saves space for dense content. Wide adds breathing room for clean reports. None is minimal padding for full-bleed layouts.

Mermaid diagrams & math formulas

Beyond standard markdown, the PDF exporter supports two powerful extensions — both render in the live preview and are fully exported to PDF.

Mermaid diagrams

Use a fenced code block tagged mermaid. Diagrams are theme-aware — colours automatically match your selected PDF theme (indigo for Light, violet for Dark, teal for Ocean, etc.):

Math formulas (KaTeX)

Write LaTeX math inside $...$ for inline or $$...$$ for block display. KaTeX renders them as crisp vector math — perfect for technical and scientific documents:

Tips for a great-looking PDF

Use a clear heading hierarchy
Start with a single H1 for the document title, H2 for sections, H3 for sub-sections. This creates a clean visual hierarchy and, in some tools, a navigable table of contents.
Specify code block languages
Write ```javascript instead of just ``` — this enables syntax highlighting in the PDF, making code blocks much easier to read.
Keep tables narrow
Wide tables often overflow the page margin. Limit columns to 4-5 and keep cell content short. If you have many columns, consider restructuring as a list.
Check image paths
Images referenced by relative path (../images/logo.png) won't load in a browser-based tool. Use absolute URLs or base64-encoded images for portable PDFs.
Choose the right font
Serif fonts (Georgia, Merriweather) work well for long-form documents. Sans-serif (Inter, Open Sans) is better for technical docs and presentations.

Frequently asked questions

Is it free to convert markdown to PDF?

Yes — the Markdown Utils converter is completely free with no limits, no sign-up, and no watermarks on the output.

Does my markdown file get uploaded to a server?

No. Everything runs in your browser. Your content never leaves your computer.

Can I convert a .md file directly?

Yes. Click the Upload button in the toolbar to load any .md or .txt file directly into the editor.

Why does my PDF have white borders?

Browsers add default margins when printing. The Export PDF button removes these automatically using @page { margin: 0 } and adds clean content padding instead.

Does it support code syntax highlighting in the PDF?

Yes. Specify the language after the opening ``` (e.g. ```python) and the PDF will include syntax-highlighted code blocks.

Can I use custom fonts?

Yes. The font dropdown includes system fonts and Google Fonts like Inter, Merriweather, Playfair Display, JetBrains Mono, and more.

📄

Ready to convert your markdown?

Free, instant, no sign-up. Upload your file or paste markdown and export in seconds.