Convert Markdown files to beautifully styled PDFs. Supports multiple themes, custom margins, and page formats.
Includes a Claude Code skill so AI assistants can convert Markdown to PDF directly.
# Using npx (no install needed)
npx md2pdf README.md
# Or install globally
npm install -g md2pdf
md2pdf document.mdmd2pdf <input.md> [options]
Options:
-o, --output <path> Output PDF path (default: same name as input)
-t, --theme <name> Theme: default, dark, minimal
-m, --margin <size> Page margin (default: 20mm)
-f, --format <size> Page format: A4, Letter, A3
-h, --help Show help
Clean sans-serif typography with GitHub-style code blocks. Best for general documents.
md2pdf document.mdDark background with light text. Ideal for technical documentation.
md2pdf document.md -t darkSerif typography (Georgia) with wider line-height and narrow column. Best for prose-heavy documents.
md2pdf document.md -t minimalconst { convert } = require('md2pdf');
await convert('document.md', {
output: 'output.pdf',
theme: 'dark',
margin: '25mm',
format: 'A4',
});This project includes a Claude Code skill that allows AI assistants to convert Markdown files to PDF.
# Clone to your plugins directory
git clone https://github.com/gewenbo888/md2pdf.git ~/.claude/plugins/md2pdf
# Or copy the skill to your skills directory
cp -r md2pdf/skills/md2pdf ~/.claude/skills/md2pdfmkdir -p ~/.claude/skills/md2pdf
cp skills/md2pdf/SKILL.md ~/.claude/skills/md2pdf/SKILL.mdOnce installed, you can ask Claude Code:
- "Convert this markdown to PDF"
- "Make a PDF from README.md with dark theme"
- "Export all .md files as PDFs"
# Basic conversion
md2pdf README.md
# Custom output path and theme
md2pdf report.md -o ~/Desktop/report.pdf -t dark
# Letter format with wider margins
md2pdf essay.md -f Letter -m 25mm -t minimal
# Convert all markdown files in a directory
for f in docs/*.md; do md2pdf "$f"; doneMIT