Claude Code · Terminal · Open source
Drawing Mermaid diagrams inside Claude Code
claude-mermaid-mod turns Mermaid blocks in Claude Code replies into Unicode diagrams, above the source, coloured with your terminal theme.
Nov 5, 2026 · 4 min read
A Mermaid block is a picture written as code. In a browser you see the picture. In a terminal you see the code, so you read a flowchart as a list of arrows and hope your head draws the right one.
claude-mermaid-mod fixes that one thing. When Claude Code writes a Mermaid block, the plugin draws it as a Unicode diagram in the reply, above the source. You keep both.
The problem
This is what Claude writes:
flowchart LR
A[Request] --> B{Cached?}
B -->|yes| C[Serve cache]
B -->|no| D[Fetch origin]
D --> CIt is correct and readable, if you are a parser. A terminal has no idea what to do with it. You open a browser or a Markdown preview, and now you are reading a diagram somewhere else.
The fix
The plugin hooks into Claude Code's reply renderer. The block is replaced by the picture as soon as the renderer knows enough, so a long answer builds up instead of appearing at the end. Switch between the two below.
mermaid-mod · both
┌─────────┐ ╔═════════╗ no ┌──────────────┐ ┌─────────────┐│ Request ├───▶║ Cached? ╟────▶│ Fetch origin ├───▶│ Serve cache │└─────────┘ ╚════╤════╝ └──────────────┘ └─────────────┘ │ ▲ └──────────────── yes ────────────────┘flowchart LR
A[Request] --> B{Cached?}
B -->|yes| C[Serve cache]
B -->|no| D[Fetch origin]
D --> CToggle it. Claude writes the block, the terminal draws the diagram above it, and the source stays underneath.
The stored message still holds the Mermaid source, so ctrl+o still shows it and copying the block is safe. This is the real thing, running in Claude Code:
What it draws
Flowcharts, state, class, ER, sequence, pie, mindmap, timeline and gitGraph. Borders, text, edges, edge labels and titles use your Claude Code theme.
It leaves the code block alone when drawing would make things worse.
- The diagram type is not supported, for example gantt.
- The diagram is wider than the terminal. Resize the window and it redraws.
- The source has errors. A warning line under the block says what failed.
With show-me
show-me is a skill by HumanLayer that asks Claude to explain a topic with diagrams. With this plugin installed, those diagrams are drawn in the terminal too. Type /show-me and you get a call tree or a sequence diagram in seconds.
Install
Give this to Claude Code. It works from any session.
Tell your agent
Install the claude-mermaid-mod plugin for Claude Code: https://github.com/ngothanhluc/claude-mermaid-mod Then run /mermaid to check the settings.
Needs Claude Code 2.1.287 or later. The two /plugin commands are in the repository README.
Settings
The plugin saves settings for every session on the machine. You set them once.
| Command | Effect |
|---|---|
/mermaid | Show the current settings |
/mermaid streaming | Draw every block, including one still being written. Default. |
/mermaid final | Draw only blocks whose closing fence has arrived |
/mermaid off | Draw nothing. Code blocks stay as they are. |
/mermaid both | Draw the diagram above its code block. Default. |
/mermaid diagram | Draw the diagram in place of its code block |
Limits
- A diagram wider than the terminal keeps its code block until you resize the window.
- Unsupported types such as gantt, and sources with errors, are never drawn. The block stays and a warning explains why.
- Streaming mode redraws while the block is still being written, which can look busy on a slow terminal.
- It needs Claude Code 2.1.287 or later.
Credits
Rendering by lovely-mermaid, Apache-2.0. The integration is a port of pi's built-in Mermaid support by xl0. The show-me skill is by HumanLayer, MIT. Code is in the repository. Open the repository.