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

mermaid-viewer-cli

v1.0.4

Published

> ✨ A sleek Node.js CLI tool to **view, edit, and export Mermaid diagrams** β€” powered by 🐚 `commander`, ⚑ `TailwindCSS`, and 🧠 `Mermaid.js`.

Downloads

17

Readme

🧭 Mermaid Diagram Viewer CLI

✨ A sleek Node.js CLI tool to view, edit, and export Mermaid diagrams β€” powered by 🐚 commander, ⚑ TailwindCSS, and 🧠 Mermaid.js.


License Node

πŸ“Έ Screenshot

View


🎨 Features

  • βœ… Beautiful HTML Preview β€” dark mode using TailwindCSS πŸŒ™
  • βœ… Monaco Editor β€” professional code editor with syntax highlighting πŸ’»
  • βœ… Split View β€” source on the left, live-rendered diagram on the right πŸͺž
  • βœ… Live Editing β€” instantly re-render as you type ✍️
  • βœ… Multiple Themes β€” Dark, Light, Forest, and Neutral themes 🎨
  • βœ… Sample Library β€” 14+ pre-built diagram examples to learn from πŸ“š
  • βœ… Zoom Controls β€” smooth control for detailed diagrams πŸ”
  • βœ… Export Options β€” download as SVG πŸ–ΌοΈ, PNG πŸ“Έ, or MMD source πŸ’Ύ
  • βœ… Keyboard Shortcuts β€” save & refresh with ease ⌨️
  • βœ… Stdin Support β€” pipe diagrams from other commands πŸ”„
  • βœ… Draggable Splitter β€” resize panes to your preference ↔️

πŸš€ Installation

npm install -g mermaid-viewer-cli

or run directly with npx:

npx mermaid-viewer-cli -f diagram.mmd

βš™οΈ Usage

πŸ”§ Basic Commands

From a file:

mermaid-viewer -f your-diagram.mmd

From stdin (auto-detected):

echo "graph TD; A-->B" | mermaid-viewer

cat diagram.mmd | mermaid-viewer -o output.html

# Using heredoc
mermaid-viewer -o chart.html <<EOF
graph TD
    A[Start] --> B[Process]
    B --> C[End]
EOF

Pipe from other commands:

# From a script
./generate-diagram.sh | mermaid-viewer --open

# From curl
curl -s https://example.com/diagram.mmd | mermaid-viewer

πŸ“‚ Options

| Option | Description | | ----------------------- | ------------------------------------------------ | | -f, --file <path> | Path to the Mermaid file (.mmd or .txt) | | -o, --out-html <path> | Output HTML file (default: mermaid-diagram.html) | | -t, --title <text> | Title for HTML page (default: Mermaid Diagram) | | --open | Open generated HTML in browser automatically |

Note: The tool auto-detects stdin input. If you pipe data, you don't need any special flag!


πŸ§‘β€πŸ’» Live Editing

  • πŸ’‘ The left pane is a Monaco editor with Mermaid syntax highlighting.
  • πŸͺ„ The right pane shows the rendered diagram in real time.
  • πŸ”„ Changes auto-render after 800ms of inactivity (debounced).
  • πŸ“š Load sample diagrams from the dropdown menu to learn syntax.

⌨️ Keyboard Shortcuts

| Shortcut | Action | | --------------- | ------------------------------- | | Ctrl+S / Cmd+S | Download Mermaid source (.mmd) | | Ctrl+R / Cmd+R | Re-render diagram | | Ctrl+B / Cmd+B | Toggle minimap in editor |


πŸ“€ Export Options

At the top-right corner, you'll find export buttons:

  • πŸ–ΌοΈ Download SVG β€” for scalable vector diagrams
  • πŸ“Έ Download PNG β€” for raster images (high resolution)
  • πŸ’Ύ Download MMD β€” save the Mermaid source code

🎨 Theme Support

Choose from 4 beautiful themes:

  • πŸŒ™ Dark (default)
  • β˜€οΈ Light
  • 🌲 Forest
  • βšͺ Neutral

Switch themes using the dropdown menu and see your diagram update instantly!


πŸ“š Sample Library

Load pre-built examples to learn Mermaid syntax:

  • Account Merge Flow
  • Apex Class Writing Flow
  • Git Operations Flow
  • ReactJS Development Flow
  • Performance Testing Flow
  • And 10+ more!

🌈 Examples

Example 1: Simple Flowchart

graph TD
    A[Start] --> B{Is it working?}
    B -->|Yes| C[Awesome! πŸŽ‰]
    B -->|No| D[Check your syntax 🧩]
    D --> B

Save it as example.mmd, then run:

mermaid-viewer -f example.mmd --open

Example 2: Salesforce Sandboxes Flow

flowchart TB

    %% Colors
    classDef dev fill:#4ade80,stroke:#166534,color:#fff;          %% green
    classDef int fill:#60a5fa,stroke:#1e3a8a,color:#fff;          %% blue
    classDef qa fill:#fbbf24,stroke:#92400e,color:#fff;           %% amber
    classDef uat fill:#f472b6,stroke:#9d174d,color:#fff;          %% pink
    classDef preprod fill:#a78bfa,stroke:#4c1d95,color:#fff;      %% purple
    classDef prod fill:#ef4444,stroke:#7f1d1d,color:#fff;         %% red

    %% Nodes
    DEV1["Dev Sandbox 1"]
    DEV2["Dev Sandbox 2"]
    DEV3["Dev Sandbox 3"]

    INT["Integration Sandbox"]
    QA["QA Sandbox"]
    UAT["UAT Sandbox"]
    PREPROD["Pre-Prod Sandbox"]
    PROD["Production Org"]

    %% Flow
    DEV1 --> INT
    DEV2 --> INT
    DEV3 --> INT

    INT --> QA
    QA --> UAT
    UAT --> PREPROD
    PREPROD --> PROD

    %% Apply classes
    class DEV1,DEV2,DEV3 dev
    class INT int
    class QA qa
    class UAT uat
    class PREPROD preprod
    class PROD prod

Pipe it directly:

cat salesforce-flow.mmd | mermaid-viewer -t "Salesforce Sandboxes" --open

Example 3: Generate from Script

#!/bin/bash
# generate-diagram.sh

echo "graph LR"
echo "    A[CI/CD Pipeline]"
echo "    A --> B[Build]"
echo "    B --> C[Test]"
echo "    C --> D[Deploy]"

Run:

./generate-diagram.sh | mermaid-viewer -o pipeline.html

🧾 UI Layout

+-------------------------------------------+-------------------------------------------+
| πŸ“ Monaco Editor (Mermaid Source)        | 🧩 Live Diagram Preview                   |
|                                           |                                           |
| - Syntax highlighting                     | - Real-time rendering                     |
| - Line numbers                            | - Zoom controls                           |
| - Minimap                                 | - Pan & scroll                            |
| - Auto-complete                           | - Grid background                         |
|-------------------------------------------|-------------------------------------------|
|                    Status Bar: Stats, Render time, Node count                        |
+--------------------------------------------------------------------------------------+

πŸ”§ Advanced Usage

Pipeline Integration

# Generate diagram from database query
psql -c "SELECT * FROM workflow" | \
  awk '{print "graph TD; " $1 "-->" $2}' | \
  mermaid-viewer -o db-flow.html

# From API response
curl -s https://api.example.com/diagram | \
  jq -r '.mermaid' | \
  mermaid-viewer --open

Continuous Preview

# Watch file and regenerate on changes
watch -n 2 'cat diagram.mmd | mermaid-viewer -o preview.html'

πŸ§‘β€πŸŽ¨ Future Enhancements

  • 🧭 Multiple tabs for multiple diagrams
  • πŸ”„ Auto-save + diagram history snapshots
  • 🌐 Web server mode for live collaboration
  • πŸ“± Responsive mobile view
  • 🎯 Direct GitHub integration

πŸ“„ License

MIT License - feel free to use this in your projects!


🧑 Credits

Built with ❀️ by Mohan Chinnappan


Happy Diagramming! πŸŽ¨πŸ“Š