Skip to content
Back to skills

Mermaid Diagrams

ASecurity

Generate PNG images from Mermaid syntax using mermaid-cli (mmdc). Supports flowcharts, sequence diagrams, ER diagrams, class diagrams, and more. Can update markdown files to replace mermaid code blocks with image links for Google Docs compatibility. Use when the user wants to convert mermaid to PNG, generate diagram images, export diagrams for docs, or says "mermaid to PNG", "diagram image", or "export diagram".

  • 3 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added December 6, 2026
ai-agentsgobashgit

Works with

  • cli

Security analysis

A96/100
  • mediumInstalls packages at runtime which could introduce malicious dependencies

Pro scans all 3 files and shows the line behind each finding

Scanned December 6, 2026

npx -y skills add flopperj/dotfiles-core --skill mermaid-diagrams --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Mermaid Diagrams?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Mermaid Diagrams
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/flopperj-mermaid-diagrams/badge)](https://www.skillsdirectory.com/skills/flopperj-mermaid-diagrams)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: mermaid-diagrams
description: Generate PNG images from Mermaid syntax using mermaid-cli (mmdc). Supports flowcharts, sequence diagrams, ER diagrams, class diagrams, and more. Can update markdown files to replace mermaid code blocks with image links for Google Docs compatibility. Use when the user wants to convert mermaid to PNG, generate diagram images, export diagrams for docs, or says "mermaid to PNG", "diagram image", or "export diagram".
user-invocable: true
---

# Mermaid Diagrams

Generate PNG diagrams from Mermaid syntax using `mmdc`.

## Prerequisites

**Check if `mmdc` is installed:**

```bash
if ! command -v mmdc &> /dev/null; then
  echo "mermaid-cli (mmdc) not found."
fi
```

**Install options (if not found):**

Option 1 — Global install (recommended for frequent use):

```bash
npm install -g @mermaid-js/mermaid-cli
```

Option 2 — Use via npx (no global install required):

```bash
npx -p @mermaid-js/mermaid-cli mmdc -i input.mmd -o output.png
```

For more information, see the [mermaid-cli GitHub repo](https://github.com/mermaid-js/mermaid-cli).

## Chrome Configuration

PNG generation requires Chrome/Puppeteer. If you encounter errors about Chrome not being found, set the `PUPPETEER_EXECUTABLE_PATH` environment variable to use your system Chrome:

```bash
export PUPPETEER_EXECUTABLE_PATH="/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"
```

Or prefix individual commands:

```bash
PUPPETEER_EXECUTABLE_PATH="/Applications/Google Chrome.app/Contents/MacOS/Google Chrome" mmdc -i diagram.mmd -o diagram.png -e png
```

## Quick Commands

### Generate PNG from .mmd file (light mode default)

```bash
mmdc -i diagram.mmd -o diagram.png -t default -b white -e png -s 4
```

### Generate from stdin

```bash
cat << 'EOF' | mmdc --input - -o output.png -t default -b white -e png -s 4
graph TD
    A[Start] --> B[End]
EOF
```

### Update markdown with diagram images

```bash
mmdc -i template.md -o output.md -t default -b white -e png -s 4
```

This extracts mermaid code blocks from markdown, generates numbered image files, and replaces blocks with `![diagram](./output-N.png)` references.

### Custom image output directory

```bash
mmdc -i template.md -o docs/README.md -a docs/images/ -t default -b white -e png -s 4
```

## Default Configuration

- **Theme**: `default` (light colors)
- **Background**: `white`
- **Scale**: `4` (4x resolution for crisp images)

For dark mode (only when requested): `-t dark -b transparent`

## Additional Resources

- For CLI options and troubleshooting, see [reference.md](reference.md)
- For diagram type examples, see [examples.md](examples.md)

Files in this skill

  • SKILL.md2.6 KB
  • examples.md2.2 KB
  • reference.md1.5 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in ai-agents →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.