Tutorials

Convert Markdown to PDF: 7 Best Methods for Every Use Case

Learn how to convert Markdown to PDF using online tools, VS Code, Pandoc, GitHub Actions, and code. Covers command line, Node.js, Python, and Mermaid support.

Eduard Albu
December 8, 2025
12 min read
#markdown-to-pdf#md-to-pdf#pandoc#vscode#online-tools#free-tools

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:

  1. Open the tool
  2. Upload your .md file or paste content
  3. Preview the result
  4. 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:

  1. Open VS Code
  2. Go to Extensions (Ctrl+Shift+X)
  3. Search "Markdown PDF"
  4. Install the extension by yzane

How to convert MD to PDF in VS Code:

  1. Open your .md file
  2. Press Ctrl+Shift+P (Cmd+Shift+P on Mac)
  3. Type "Markdown PDF: Export (pdf)"
  4. 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-recommended

On macOS:

brew install pandoc
brew install --cask mactex

On Windows, download from pandoc.org.

Basic Commands

Basic conversion:

pandoc input.md -o output.pdf

With syntax highlighting:

pandoc input.md -o output.pdf --highlight-style=tango

With custom margins:

pandoc input.md -o output.pdf -V geometry:margin=1in

With table of contents:

pandoc input.md -o output.pdf --toc

Why 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/*.pdf

This 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

  1. Open your note
  2. Click the three-dot menu
  3. Select "Export to PDF"

For Better Results: Use the Pandoc Plugin

  1. Install the "Pandoc Plugin" from Community Plugins
  2. Configure your Pandoc path in settings
  3. 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-pdf
const { 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-pdf
const 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 md2pdf
from 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 pypandoc
import pypandoc

output = pypandoc.convert_file('input.md', 'pdf', outputfile='output.pdf')

Option 3: Jupyter Notebooks

If your Markdown is in a Jupyter notebook:

  1. File → Download as → PDF via LaTeX

Or from command line:

jupyter nbconvert --to pdf notebook.ipynb

Comparison: Which Method Should You Use?

MethodSpeedSetupCustomizationBest For
Online toolInstantNoneLimitedQuick one-off conversions
VS CodeFastExtension installMediumDevelopers in VS Code
Pandoc CLIFastInstall requiredFullAutomation, batch jobs
GitHub ActionsAutomatedConfig fileFullCI/CD pipelines
ObsidianFastPlugin optionalLimitedNote-taking workflows
Node.jsVariesnpm installFullWeb apps, custom tools
PythonVariespip installFullData 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.