Mermaid: Network Diagrams in Code
Dec 2, 2025
toolsdiagramsdocumentation
Mermaid lets you create diagrams using plain text. No more wrestling with Visio, Lucidchart, or drag-and-drop editors that produce unmaintainable binary files.
Why Text-Based Diagrams Win
- Version control friendly β diffs show exactly what changed
- Lives with your code β diagrams stay in sync with the system they describe
- No context switching β write diagrams in the same editor as your code
- AI-friendly β LLMs can generate and modify diagrams easily
Network Diagram Example
graph LR
Internet((Internet)) --> LB[Load Balancer]
LB --> Web1[Web Server 1]
LB --> Web2[Web Server 2]
Web1 --> DB[(Database)]
Web2 --> DB
Web1 --> Cache[(Redis)]
Web2 --> Cache
This renders as a clear left-to-right network topology showing traffic flow from the internet through a load balancer to web servers, with shared database and cache backends.
More Than Just Flowcharts
Mermaid supports:
- Sequence diagrams β API call flows, authentication sequences
- Class diagrams β object relationships
- State diagrams β state machines
- Entity-relationship diagrams β database schemas
- Gantt charts β project timelines
- Git graphs β branch visualization
Where It Works
Mermaid renders natively in:
- GitHub (README, issues, PRs, wikis)
- GitLab
- Notion
- Obsidian
- VS Code (with extensions)
- Most documentation tools (Docusaurus, MkDocs, etc.)
The Mental Shift
Traditional diagramming tools optimize for visual editing. Mermaid optimizes for describing relationships. You think about what connects to what, not where boxes should be positioned.
The layout engine handles placement automatically. Sometimes itβs not perfect, but for documentation purposes, clarity beats pixel-perfect positioning.
Getting Started
Drop this into any GitHub markdown file:
```mermaid
graph TD
A[Start] --> B{Decision}
B -->|Yes| C[Do Thing]
B -->|No| D[Other Thing]
```
Thatβs it. No setup, no accounts, no exports. Your diagram lives as text, renders as graphics, and stays maintainable forever.