termaid
Render Mermaid diagrams in your terminal, in Claude Code, or in your Python app.
Try it online at termaid.com
Features
- Draws the Mermaid diagrams in Claude Code's replies as they stream (setup). It also draws the Mermaid blocks in Markdown files
- 18 diagram types: flowcharts, sequence, class, ER, state, block, git, gantt, architecture, pie, treemap, mindmap, timeline, kanban, quadrant, XY chart, user journey, and packet
- No dependencies. The core is pure Python
- Fits the terminal width: it tightens spacing first, then wraps labels at word boundaries
- Colored output with Rich and a TUI widget for Textual, as optional extras, with 11 themes
--ascii for terminals without box-drawing characters
- Reads from a file or stdin:
cat diagram.mmd | termaid
Install
Pip
pip install termaid
Homebrew
brew install termaid
Or try it without installing:
uvx termaid diagram.mmd
Claude Code plugin
The plugin carries its own copy of termaid. It needs Python 3.9 or later as python3 or python, which macOS and most Linux systems already have. Run this in Claude Code 2.1.275 or later:
/plugin install termaid --marketplace fasouto/termaid
Claude Code then draws the Mermaid diagrams in Claude's replies. Ask for a diagram in plain words, for example:
- "Draw a diagram of the main components of this app and how they connect"
- "Show what happens when a user logs in, as a sequence diagram"
- "Draw the database models and how they relate"
- "Draw the states an order goes through, from cart to delivery"
- "Turn this migration plan into a gantt chart"
Claude Code covers older versions and a setup without the plugin.
Quick start
CLI
termaid diagram.mmd
echo "graph LR; A-->B-->C" | termaid
termaid diagram.mmd --theme neon
termaid diagram.mmd --ascii
termaid --markdown README.md # draw every ```mermaid block in a document
gh pr view 42 | termaid --markdown
Python
from termaid import render
print(render("graph LR\n A --> B --> C"))
# Colored output (requires: pip install termaid[rich])
from termaid import render_rich
from rich import print as rprint
rprint(render_rich("graph LR\n A --> B", theme="terra"))
# Textual TUI widget (requires: pip install termaid[textual])
from termaid import MermaidWidget
widget = MermaidWidget("graph LR\n A --> B")
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? │
│ │
└──────◇──────┘
│
│
├──────────────────╮No
Yes│ │
▼ ▼
╭─────────────╮ ┌─────────────┐
│ │ │ │
│ Process │ │ Error │
│ │ │ │
╰──────┬──────╯ └─────────────┘
│
│
▼
╭─────────────╮
( )
( Done )
( )
╰─────────────╯
Node shapes: rectangle [text], rounded (text), diamond {text}, stadium ([text]), subroutine [[text]], circle ((text)), double circle (((text))), hexagon {{text}}, cylinder [(text)], asymmetric >text], parallelogram [/text/], trapezoid [/text\], and @{shape} syntax
Edge styles: solid -->, dotted -.->, thick ==>, bidirectional <-->, circle endpoint --o, cross endpoint --x, labeled -->|text|, variable length --->, ---->
Styling: classDef, style, linkStyle directives, :::className suffix
Subgraphs: nesting, cross-boundary edges, per-subgraph direction override
Other: %% comments, ; line separators, Markdown labels "`**bold** *italic*`", & operator (A & B --> C), entity codes (#quot;, #amp;, #9829;)
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 -->>, solid line ->, dashed line -->
Participants: participant, actor, aliases
Class diagrams