A powerful CLI tool and Browser Extension (Manifest V3) to convert Markdown (
.md) files, raw text, or web pages into beautifully styled, high-quality PDF & static HTML documents. Built with support for Cover Pages, Dotted Leader Line Table of Contents (TOC), Mermaid.js diagrams, LaTeX Math, GitHub Callout Alerts, Custom CSS Injection, 7 Preset Themes, and Open-Source Font Selection.
- π§© Browser Extension (Manifest V3):
- Drag & drop single or multiple
.mdfiles directly into the popup. - Auto-saved draft text in popup & conversion history list with 1-click re-open.
- Convert active web page or GitHub raw Markdown files with 1 click.
- Context menu integration: Right-click selected Markdown text or any page -> "Convert to PDF".
- Full-page Print Preview with live theme switching, Font Selector, Auto TOC, Custom CSS, and native PDF/HTML export.
- Drag & drop single or multiple
- π Auto Cover Page Generator: Generate elegant document report cover pages via YAML Front Matter (
cover: true) or--coverflag. - π Dotted Leader Line Table of Contents (TOC): Auto-generates publication-grade TOC with dotted leader lines (
...) and clickable anchor links (--toc). - π¨ 7 Preset Themes:
modern(default),dark,academic,github,ebook,cyberpunk, andminimal. - π€ Open-Source Font Selector: 100% free under SIL OFL / Apache 2.0 (
Inter,Roboto,Lora,Merriweather,JetBrains Mono,Fira Code). - β‘ Live Watch Mode & HTML Export: Real-time auto-recompilation on file changes (
-w, --watch) and direct static HTML export (-f, --format html). - π CLI & Batch Conversion: Convert single files or batch process directories with wildcard patterns.
- π¨ Custom CSS Injection: Inject custom branding CSS stylesheets (
-c, --css custom.css). - π Mermaid Diagrams: Sequence diagrams (with auto note wrapping), flowcharts, class diagrams, and gantt charts.
- π LaTeX Math Support: Mathematical equations rendered with KaTeX.
- π‘ GitHub Callout Box Alerts: Support for
> [!NOTE],> [!TIP],> [!WARNING],> [!IMPORTANT], and> [!CAUTION]. - π» ASCII UI Mockups: Styled dark-theme boxes for terminal output & ASCII wireframe mockups.
You can install the official published extension directly with 1-click: π Install Markdown to PDF Converter on Chrome Web Store
- Clone or download this repository:
git clone https://github.com/vannt-dev/convert-md-to-pdf.git
- Open your browser and navigate to
chrome://extensions(oredge://extensions). - Enable Developer mode (toggle in the top-right corner).
- Click Load unpacked (TαΊ£i tiα»n Γch ΔΓ£ giαΊ£i nΓ©n).
- Select the
extensiondirectory inside this repository (or loaddist/extension-latest.zip). - The Markdown to PDF Converter icon will appear in your browser toolbar!
npm install -g convert-md-to-pdfor run directly with npx:
npx convert-md-to-pdf input.md# Convert a Markdown file with Cover Page, Auto TOC & Cyberpunk Theme
npx convert-md-to-pdf input.md --cover --toc -t cyberpunk --font "Fira Code" -o output.pdf
# Watch file and auto-recompile on save
npx convert-md-to-pdf input.md -w -f html
# Batch convert multiple files to an output directory
npx convert-md-to-pdf file1.md file2.md -o output_dir/
# Convert entire directory of .md files
npx convert-md-to-pdf ./docs/ -o ./dist/| Flag | Alias | Description | Default |
|---|---|---|---|
-o, --output <path> |
Output PDF/HTML file path or target directory | Auto-derived | |
-f, --format <format> |
Output format: pdf, html |
pdf |
|
-w, --watch |
Live watch input file and auto-recompile on change | false |
|
-t, --theme <theme> |
Theme: modern, dark, academic, github, ebook, cyberpunk, minimal |
modern |
|
--font <font> |
Font family: Inter, Roboto, Lora, Merriweather, JetBrains Mono, Fira Code |
Inter |
|
--cover |
Auto-generate document report Cover Page | false |
|
--toc |
Auto-generate Table of Contents with Dotted Leader Lines | false |
|
-p, --page-size <size> |
Paper size: A4, Letter, A3, Legal |
A4 |
|
-l, --landscape |
Use landscape page orientation | false |
|
-m, --margin <margin> |
Custom page margin (e.g. 14mm 12mm 16mm 12mm) |
14mm 12mm 16mm 12mm |
|
-c, --css <path> |
Custom CSS stylesheet file path to inject | ||
-k, --keep-html |
Keep temporary HTML file after conversion | false |
|
--no-mermaid |
Disable Mermaid diagram rendering | false |
|
--no-katex |
Disable KaTeX math formula rendering | false |
You can specify conversion settings directly inside your .md files using YAML Front Matter:
---
title: "Quarterly Financial Report"
subtitle: "Q3 Fiscal Summary"
author: "Engineering Team"
date: "2026-08-11"
cover: true
toc: true
theme: github
font: Inter
pageSize: A4
landscape: false
---
# Document Executive Summary
...This project follows standard Git Flow branching and automated release publishing:
main: Production-ready branch. Stores stable releases. Merging code intomainautomatically triggers a GitHub Release.develop: Active development branch. Daily commits, feature additions, and refactoring take place here.
Whenever code is merged from develop into main (or a version tag v* is pushed), GitHub Actions (.github/workflows/release.yml) automatically:
- Runs full unit test suite (
npm test). - Bundles cross-platform extension zip artifacts (
dist/extension-vX.Y.Z.zip). - Auto-generates release notes from commit history.
- Publishes a new official GitHub Release with downloadable ZIP binaries attached!
You can also bump version and trigger a release with a single CLI command:
npm run release <version|patch|minor|major>
# Example: npm run release 1.2.0Please review our Git Commit & Push Workflow Guide (GIT_WORKFLOW.md) for conventional commit guidelines and pre-commit checks.
convert-md-to-pdf/
βββ bin/
β βββ cli.js # CLI executable with watch & format options
βββ src/
β βββ core/ # Shared modular conversion engine
β β βββ themes/ # Modular Theme CSS collection
β β β βββ index.js # Theme registry & font override builder
β β β βββ cover.js # Cover page CSS
β β β βββ modern.js # Modern blue theme
β β β βββ dark.js # Dark slate theme
β β β βββ academic.js # Academic serif theme
β β β βββ github.js # GitHub light theme
β β β βββ ebook.js # E-Book paper theme
β β β βββ cyberpunk.js # Cyberpunk neon dark theme
β β β βββ minimal.js # Minimal monochrome theme
β β βββ frontmatter.js # YAML front matter parser
β β βββ cover.js # Cover page generator
β β βββ toc.js # Dotted leader line TOC generator
β β βββ sanitizer.js # HTML sanitizer & escaping
β β βββ utils.js # Preprocessors & helper re-exports
β β βββ parser.js # Pipeline parser (Markdown -> HTML)
β β βββ templates.js # HTML document template builder
β β βββ index.js # Main library API entrypoint
β βββ browser/ # Headless browser rendering engine
β βββ renderer.js # Puppeteer Chrome/Edge launcher & PDF worker pool
βββ extension/ # Browser Extension (Manifest V3)
β βββ manifest.json
β βββ background/ # Service worker & context menus
β βββ content/ # Content script for raw MD pages
β βββ popup/ # Extension Popup UI (Batch file, Paste, Page, History)
β βββ preview/ # Print Preview & PDF/HTML export page
β βββ lib/ # Vendor libraries (marked, mermaid, katex)
β βββ icons/ # Extension icons (16, 48, 128)
βββ tests/ # Standalone test suite (7/7 PASS)
β βββ index.test.js
βββ dist/ # Built Chrome Extension zip artifacts
βββ examples/ # Usage examples & custom CSS templates
βββ package.json
βββ README.md
βββ PRIVACY_POLICY.md
βββ GIT_WORKFLOW.md
Distributed under the MIT License. See LICENSE for details.