Markdown is everywhere. Developers use it for README files, writers use it for drafts, and teams use it for documentation. But when you need to share your work with someone who does not use Markdown, PDF is the universal format.
The problem? There are dozens of ways to convert Markdown to PDF, and most guides only cover one or two methods.
This article breaks down the 7 best ways to convert MD to PDF, from quick online tools to command line options, VS Code extensions, and programmatic solutions. Pick the method that fits your workflow.
1. Online Converter (Fastest Option)
Best for: Quick one-off conversions, no installation required
If you need to convert Markdown to PDF right now without installing anything, an online converter is the fastest path.
QuickTools.one Markdown to PDF
Try it here: QuickTools.one/md-to-pdf
This free online tool lets you upload .md files or paste Markdown content directly. It supports GitHub-flavored Markdown including tables, task lists, and fenced code blocks with syntax highlighting.
Why it stands out:
- Runs entirely in your browser (no file uploads to servers)
- Supports GitHub Markdown syntax
- Code blocks render with syntax highlighting
- No account, no watermarks, no limits
How to use it:
- Open the tool
- Upload your .md file or paste content
- Preview the result
- Click Convert to PDF
For users who need a quick Markdown to PDF conversion without setup, this is the simplest option.
2. VS Code Extension (Best for Developers)
Best for: Developers who already work in VS Code
If you write Markdown in VS Code, converting to PDF without leaving your editor saves time. This is the most popular method for MD to PDF in VS Code.
Markdown PDF Extension
The most popular option is the "Markdown PDF" extension by yzane.
Installation:
- Open VS Code
- Go to Extensions (Ctrl+Shift+X)
- Search "Markdown PDF"
- Install the extension by yzane
How to convert MD to PDF in VS Code:
- Open your .md file
- Press Ctrl+Shift+P (Cmd+Shift+P on Mac)
- Type "Markdown PDF: Export (pdf)"
- Select the command
The PDF generates in the same directory as your Markdown file.
Customization options:
- Custom CSS styling
- Header and footer templates
- Page size and margins
- Syntax highlighting themes
Tip: Create a .vscode/settings.json file in your project to set default export options for your team.
3. Command Line with Pandoc (Most Powerful)
Best for: Batch conversions, automation, advanced formatting
Pandoc is the Swiss Army knife of document conversion. It handles Markdown to PDF from the command line with more control than any other tool.
Installation
On Ubuntu/Debian:
sudo apt install pandoc texlive-latex-base texlive-fonts-recommendedOn macOS:
brew install pandoc
brew install --cask mactexOn Windows, download from pandoc.org.
Basic Commands
Basic conversion:
pandoc input.md -o output.pdfWith syntax highlighting:
pandoc input.md -o output.pdf --highlight-style=tangoWith custom margins:
pandoc input.md -o output.pdf -V geometry:margin=1inWith table of contents:
pandoc input.md -o output.pdf --tocWhy Pandoc is worth learning:
- Converts between 40+ formats
- Supports LaTeX for academic papers
- Handles citations and bibliographies
- Works in CI/CD pipelines
The learning curve is steeper than online tools, but Pandoc gives you complete control over the output. It's the go-to for Markdown to PDF on Ubuntu and other Linux systems.
4. GitHub Actions (Automated Workflow)
Best for: Automatically generating PDFs when documentation changes
If your Markdown lives in a GitHub repository, you can automatically convert it to PDF on every push. This is ideal for GitHub Markdown to PDF workflows.
Example Workflow
Create .github/workflows/md-to-pdf.yml:
name: Convert Markdown to PDF
on:
push:
paths:
- 'docs/**/*.md'
jobs:
convert:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Pandoc
run: sudo apt-get install -y pandoc texlive-latex-base
- name: Convert to PDF
run: |
for file in docs/*.md; do
pandoc "$file" -o "${file%.md}.pdf"
done
- name: Upload PDFs
uses: actions/upload-artifact@v4
with:
name: pdf-docs
path: docs/*.pdfThis workflow converts all Markdown files in the docs/ folder to PDF whenever they change.
Use cases:
- Generating PDF documentation for releases
- Creating printable versions of README files
- Building PDF reports from Markdown templates
5. Obsidian (Best for Note-Takers)
Best for: Converting personal notes and knowledge bases
Obsidian users can export notes to PDF directly from the app, making it a popular choice for Markdown to PDF in Obsidian.
Built-in Export
- Open your note
- Click the three-dot menu
- Select "Export to PDF"
For Better Results: Use the Pandoc Plugin
- Install the "Pandoc Plugin" from Community Plugins
- Configure your Pandoc path in settings
- Use the command palette to export
Tip: Obsidian's built-in export works for simple notes. For complex documents with code blocks or tables, the Pandoc plugin produces cleaner output.
6. Node.js / JavaScript (Programmatic)
Best for: Building tools, generating PDFs in web apps
If you need to convert Markdown to PDF with Node.js programmatically, several libraries handle this well.
Option 1: md-to-pdf
npm install md-to-pdfconst { mdToPdf } = require('md-to-pdf');
async function convert() {
const pdf = await mdToPdf({ path: 'input.md' });
fs.writeFileSync('output.pdf', pdf.content);
}
convert();Option 2: markdown-pdf
npm install markdown-pdfconst markdownpdf = require('markdown-pdf');
markdownpdf()
.from('input.md')
.to('output.pdf', function() {
console.log('Done');
});Option 3: Puppeteer + marked (Full Control)
const puppeteer = require('puppeteer');
const { marked } = require('marked');
const fs = require('fs');
async function mdToPdf(inputPath, outputPath) {
const markdown = fs.readFileSync(inputPath, 'utf8');
const html = marked(markdown);
const browser = await puppeteer.launch();
const page = await browser.newPage();
await page.setContent(`
<html>
<head>
<style>
body { font-family: system-ui; max-width: 800px; margin: 0 auto; padding: 40px; }
pre { background: #f5f5f5; padding: 16px; overflow-x: auto; }
code { font-family: monospace; }
</style>
</head>
<body>${html}</body>
</html>
`);
await page.pdf({ path: outputPath, format: 'A4' });
await browser.close();
}
mdToPdf('input.md', 'output.pdf');The Puppeteer approach gives you complete control over styling and is useful when building custom tools.
7. Python (Data Science and Automation)
Best for: Data scientists, Python-based workflows
Python users can convert Markdown to PDF with Python using several approaches.
Option 1: md2pdf
pip install md2pdffrom md2pdf.core import md2pdf
md2pdf(
pdf_file_path='output.pdf',
md_file_path='input.md',
css_file_path='style.css' # optional
)Option 2: pypandoc (Pandoc Wrapper)
pip install pypandocimport pypandoc
output = pypandoc.convert_file('input.md', 'pdf', outputfile='output.pdf')Option 3: Jupyter Notebooks
If your Markdown is in a Jupyter notebook:
- File → Download as → PDF via LaTeX
Or from command line:
jupyter nbconvert --to pdf notebook.ipynbComparison: Which Method Should You Use?
| Method | Speed | Setup | Customization | Best For |
|---|---|---|---|---|
| Online tool | Instant | None | Limited | Quick one-off conversions |
| VS Code | Fast | Extension install | Medium | Developers in VS Code |
| Pandoc CLI | Fast | Install required | Full | Automation, batch jobs |
| GitHub Actions | Automated | Config file | Full | CI/CD pipelines |
| Obsidian | Fast | Plugin optional | Limited | Note-taking workflows |
| Node.js | Varies | npm install | Full | Web apps, custom tools |
| Python | Varies | pip install | Full | Data science, automation |
Special Cases
Markdown to PDF with Mermaid Diagrams
Mermaid diagrams in Markdown require special handling. Most basic converters do not render them.
Solutions:
- Pandoc + mermaid-filter: Install the filter and use
--filter mermaid-filter - md-to-pdf: Supports Mermaid out of the box
- VS Code: Use the Markdown Preview Mermaid Support extension first, then export
Markdown to PDF with GitHub Styling
Want your PDF to look like GitHub's Markdown preview?
Options:
- Use a GitHub-style CSS file with Pandoc:
pandoc input.md -o output.pdf --css=github.css - The QuickTools.one converter uses clean styling similar to GitHub's rendering
Markdown Resume to PDF
Converting a Markdown resume to PDF is a common use case.
Tips:
- Use a single-column layout
- Keep it to one page
- Use a clean CSS stylesheet
- Test the PDF in different viewers
Conclusion
The best Markdown to PDF method depends on your workflow:
- Need it now? Use QuickTools.one
- Working in VS Code? Install the Markdown PDF extension
- Automating builds? Set up Pandoc in your CI pipeline
- Building an app? Use md-to-pdf or Puppeteer in Node.js
All these methods produce clean PDFs. Pick the one that fits where you already work.
Your files stay private. Your workflow stays fast. And you stay in control.