npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

markdown-to-pdf-cli

v1.0.2

Published

Convert Markdown files to PDF with Mermaid diagram support

Readme

md2pdf-cli 📄

A powerful command-line tool to convert Markdown files to beautifully formatted PDFs with full Mermaid diagram support.

✨ Features

  • 🎨 Beautiful PDF Output: A4-wide, infinite-scroll PDFs with clean formatting
  • 📊 Mermaid Support: Full support for Mermaid diagrams (flowcharts, sequence diagrams, etc.)
  • 🖥️ Interactive CLI: User-friendly prompts when run without arguments
  • 👀 Watch Mode: Auto-regenerate PDFs when markdown files change
  • 📦 Batch Processing: Convert multiple files at once using glob patterns
  • ⚡ Progress Indicators: Visual feedback during conversion
  • 🎯 Zero Configuration: Works out of the box with sensible defaults

🚀 Installation

Global Installation (Recommended)

npm install -g markdown-to-pdf-cli

Local Installation

npm install markdown-to-pdf-cli
npx md2pdf --help

📖 Usage

Interactive Mode

Simply run without arguments for guided prompts:

md2pdf

Command Line Options

# Convert a single file
md2pdf -i document.md -o output.pdf

# Use default output filename (document.pdf)
md2pdf -i document.md

# Watch mode - auto-regenerate on changes
md2pdf -i document.md --watch

# Batch convert multiple files
md2pdf --batch "docs/*.md"

# Interactive mode explicitly
md2pdf --interactive

Full Command Reference

Options:
  -i, --input <file>        Input markdown file
  -o, --output <file>       Output PDF file
  -c, --config <file>       Optional config file (JSON)
  -w, --watch               Watch mode - regenerate PDF when markdown file changes
  -b, --batch <pattern>     Batch process multiple files using glob pattern
  --interactive             Interactive mode with prompts
  -h, --help               Display help for command
  -V, --version            Display version number

📝 Markdown Support

Standard Markdown

  • Headers, paragraphs, lists
  • Code blocks with syntax highlighting
  • Tables, links, images
  • Bold, italic, strikethrough text

Mermaid Diagrams

Full support for all Mermaid diagram types:

```mermaid
graph TD
    A[Start] --> B{Decision}
    B -->|Yes| C[Action 1]
    B -->|No| D[Action 2]
    C --> E[End]
    D --> E
```

Supported diagram types:

  • Flowcharts
  • Sequence diagrams
  • Class diagrams
  • State diagrams
  • Entity relationship diagrams
  • User journey diagrams
  • Gantt charts
  • Pie charts
  • And more!

🛠️ Examples

Basic Conversion

md2pdf -i README.md
# Creates README.pdf

Watch Mode for Development

md2pdf -i documentation.md --watch
# Automatically regenerates PDF when documentation.md changes

Batch Processing

# Convert all markdown files in docs folder
md2pdf --batch "docs/*.md"

# Convert all markdown files recursively
md2pdf --batch "**/*.md"

Interactive Mode

md2pdf --interactive
# Guided prompts for file selection and options

🔧 Configuration

Create a config.json file for custom settings:

{
  "theme": "neutral",
  "pageWidth": "210mm",
  "margin": {
    "top": "20mm",
    "right": "20mm",
    "bottom": "20mm",
    "left": "20mm"
  }
}

Use with:

md2pdf -i document.md -c config.json

📋 Requirements

  • Node.js 16 or higher
  • Chrome/Chromium (automatically downloaded by Puppeteer)

🤝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

📄 License

MIT License - see LICENSE file for details.

🐛 Issues

Found a bug or have a feature request? Please open an issue on GitHub.

💡 Tips

  • Use descriptive filenames for better organization
  • Mermaid diagrams render best with clean, simple syntax
  • Watch mode is perfect for iterative document development
  • Batch processing saves time when converting multiple files
  • Interactive mode is great for occasional use

Made with ❤️ for the developer community