mermaid-viewer-cli
v1.0.3
Published
> β¨ A sleek Node.js CLI tool to **view, edit, and export Mermaid diagrams** β powered by π `commander`, β‘ `TailwindCSS`, and π§ `Mermaid.js`.
Downloads
197
Maintainers
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.
πΈ Screenshot

π¨ Features
- β Beautiful HTML Preview β dark mode using TailwindCSS π
- β Split View β source on the left, live-rendered diagram on the right πͺ
- β Live Editing β instantly re-render as you type βοΈ
- β Zoom In / Out β smooth control for detailed diagrams π
- β Export Options β download as SVG πΌοΈ or PNG πΈ
- β Keyboard Shortcuts β save & refresh with ease β¨οΈ
- β
Local File Support β provide a
.mmdfile via CLI
π Installation
npm install -g mermaid-viewer-clior run directly with npx:
npx mermaid-viewer-cli -f diagram.mmdβοΈ Usage
π§ Basic Command
mermaid-viewer -f your-diagram.mmdπ Options
| Option | Description |
| --------------------- | ----------------------------------------------- |
| -f, --file <path> | Path to the Mermaid file (.mmd or .mermaid) |
| -p, --port <number> | Specify port for local preview (default: 3000) |
π§βπ» Live Editing
- π‘ The left pane is your editable Mermaid source code.
- πͺ The right pane shows the rendered diagram in real time.
- π§· Press Ctrl+S (or Cmd+S) to save changes back to the file.
π€ Export Options
At the top-right corner, youβll find export buttons:
- πΌοΈ Download SVG β for scalable vector diagrams
(Make sure you allow pop-ups in your browser for download dialogs.)
π Example
Hereβs a sample Mermaid file you can test with:
graph TD
A[Start] --> B{Is it working?}
B -->|Yes| C[Awesome! π]
B -->|No| D[Check your syntax π§©]
D --> BSave it as example.mmd, then run:
mermaid-viewer -f example.mmdπ§Ύ Example Output
π₯οΈ The app opens a browser window that looks like this:
+-------------------------------------------+-------------------------------------------+
| π Mermaid Source | π§© Live Diagram |
|-------------------------------------------|-------------------------------------------|
| graph TD | [Rendered Flowchart] |
| A --> B | |
| B --> C | |
|-------------------------------------------|-------------------------------------------|
| Ctrl+S to save Β· Zoom controls Β· Export | |
+-------------------------------------------+-------------------------------------------+Salesforce sandboxes example
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
π§βπ¨ Future Enhancements
- π§ Multiple tabs for multiple diagrams
- π§± Syntax highlighting for Mermaid editor
- π Auto-save + diagram history snapshots
π§‘ Credits
Built with β€οΈ by Mohan Chinnappan
