1 unstable release
| 0.1.0 | Mar 30, 2026 |
|---|
#1532 in Parser implementations
96KB
2K
SLoC
meraid
Render Mermaid diagrams in your terminal or Rust application.
Features
- Pure Rust implementation — Zero external dependencies, blazing fast, fully portable
- AI-friendly — JSON output mode for programmatic parsing, perfect for AI coding agents
- 5+ diagram types — Flowcharts, sequence diagrams, class diagrams, state diagrams, pie charts
- 6 color themes — default, terra, neon, mono, amber, phosphor
- ASCII fallback — Works on any terminal, even the most basic ones
- Pipe-friendly CLI —
cat diagram.mmd | meraidjust works
Why Meraid?
Mermaid is excellent for documentation, but rendering it typically requires a browser or external service. Meraid brings Mermaid rendering directly to your terminal — perfect for SSH sessions, CI logs, TUI applications, or any environment with Rust.
Built with love for the Rust ecosystem, providing a fast, dependency-free alternative to existing solutions.
Install
From Git (Recommended - Latest)
cargo install --git https://github.com/Binlogo/meraid.git
From Source
git clone https://github.com/Binlogo/meraid.git
cd meraid
cargo build --release
cargo install --path .
From Crates.io (Coming Soon)
cargo install meraid
With Homebrew (coming soon)
brew install meraid
Quick Start
CLI
# Render from file
meraid diagram.mmd
# Render from stdin
echo "graph LR; A-->B-->C" | meraid
# Use a theme
meraid diagram.mmd --theme neon
# ASCII-only output
meraid diagram.mmd --ascii
# JSON output (AI-friendly)
meraid diagram.mmd --format json
Rust Library
use meraid::{render, ThemeType};
fn main() {
let diagram = render("graph LR\n A --> B --> C", ThemeType::Default).unwrap();
println!("{}", diagram);
}
Supported Diagram Types
Flowcharts
All directions supported: LR, RL, TD/TB, BT.
graph TD
A[Start] --> B{Is valid?}
B -->|Yes| C(Process)
C --> D([Done])
B -->|No| E[Error]
┌─────────────┐
│ │
│ Start │
│ │
└──────┬──────┘
│
▼
┌──────◇──────┐
│ │
│ Is valid? │
│ │
└──────◇──────┘
│
╰──────────────────╮
Yes│ │No
▼ ▼
╭─────────────╮ ┌─────────────┐
│ │ │ │
│ Process │ │ Error │
│ │ │ │
╰──────┬──────╯ └─────────────┘
│
▼
╭─────────────╮
( )
( Done )
( )
╰─────────────╯
Node shapes: rectangle [text], rounded (text), diamond {text}, stadium ([text]), subroutine [[text]]
Edge styles: solid -->, dotted -.->, thick ==>, labeled -->|text|
Sequence Diagrams
sequenceDiagram
Alice->>Bob: Hello Bob
Bob-->>Alice: Hi Alice
Alice->>Bob: How are you?
Bob-->>Alice: Great!
┌──────────┐ ┌──────────┐
│ Alice │ │ Bob │
└──────────┘ └──────────┘
┆ Hello Bob ┆
──────────────────►
┆ Hi Alice ┆
◄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄
┆ How are you? ┆
──────────────────►
┆ Great! ┆
◄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄
Message types: solid arrow ->>, dashed arrow -->>
Participants: participant, actor, aliases
Class Diagrams
classDiagram
class Animal {
+String name
+int age
+makeSound()
}
class Dog {
+String breed
+fetch()
}
Animal <|-- Dog
┌──────────────┐
│ Animal │
├──────────────┤
│ +String name │
│ +int age │
├──────────────┤
│ +makeSound() │
└──────────────┘
△
│
┌───────────────┐
│ Dog │
├───────────────┤
│ +String breed │
├───────────────┤
│ +fetch() │
└───────────────┘
Relationships: inheritance <|--, composition *--, aggregation o--, association --
Members: attributes and methods with visibility (+ public, - private, # protected)
State Diagrams
stateDiagram-v2
[*] --> Idle
Idle --> Processing: start
Processing --> Done: complete
Done --> [*]
╭───────◯──────╮
│ │
│ ● │
│ │
╰───────◯──────╯
│
▼
╭──────────────╮
│ │
│ Idle │
│ │
╰───────┬──────╯
│
start│
▼
╭──────────────╮
│ │
│ Processing │
│ │
╰───────┬──────╯
│
complete│
▼
╭──────────────╮
│ │
│ Done │
│ │
╰───────┬──────╯
│
▼
╭───────◯──────╮
│ │
│ ◉ │
│ │
╰───────◯──────╯
Features: [*] start/end states, transition labels, composite states
Pie Charts
pie title Pets adopted by volunteers
"Dogs" : 386
"Cats" : 85
"Rats" : 15
Dogs┃████████████████████████████████ 79.4%
Cats┃▓▓▓▓▓▓▓ 17.5%
Rats┃░ 3.1%
ER Diagrams
erDiagram
CUSTOMER {
int id PK
string name
string email
}
ORDER {
int id PK
int customer_id FK
date order_date
}
CUSTOMER ||--o{ ORDER : places
┌────────────────────┐
│ CUSTOMER │
├────────────────────┤
│PK : id │
│ : name │
│ : email │
└────────────────────┘
┌────────────────────┐
│ ORDER │
├────────────────────┤
│PK : id │
│ FK : customer_id │
│ : order_date │
└────────────────────┘
CUSTOMER ||--o{ ORDER
Cardinality notation:
||exactly one}|one or moreo|zero or oneo{zero or more
Attribute markers:
PKprimary keyFKforeign key
CLI Options
| Flag | Description |
|---|---|
--ascii |
ASCII-only output (no Unicode box-drawing) |
--theme NAME |
Color theme. Options: default, terra, neon, mono, amber, phosphor |
--padding-x N |
Horizontal padding inside boxes (default: 4) |
--padding-y N |
Vertical padding inside boxes (default: 2) |
--width N |
Max output width (default: 120) |
--sharp-edges |
Sharp corners on edge turns instead of rounded |
--format FORMAT |
Output format: text or json (AI-friendly) |
Themes
6 built-in themes:
| Theme | Colors | Description |
|---|---|---|
default |
Cyan nodes, yellow arrows | Default terminal colors |
terra |
Warm earth tones (browns, oranges) | Retro/vintage feel |
neon |
Magenta nodes, green arrows | Cyberpunk style |
mono |
White/gray monochrome | Simple and clean |
amber |
Amber/gold CRT-style | Classic amber monitor |
phosphor |
Green phosphor terminal-style | Classic green terminal |
Roadmap
- ER diagrams ✅
- Block diagrams
- Git graphs
- Treemaps
- Mindmaps
- More themes (gruvbox, monokai, dracula, nord, solarized)
- Auto-fit to terminal width
- Interactive TUI viewer
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
Acknowledgements
Inspired by termaid by fasouto.
License
MIT License — see LICENSE for details.
Made with ❤️ in Rust
Dependencies
~5.5–8MB
~136K SLoC