Creating Beautiful Diagrams with Mermaid
Learn to create flowcharts, sequence diagrams, and Gantt charts using simple text-based Mermaid syntax in your Markdown documents.
Jacky
Mermaid lets you create diagrams and visualizations using a simple text-based syntax directly in your Markdown files. No more switching between tools or embedding static images — your diagrams live alongside your documentation and can be version-controlled.
Why Mermaid?
Traditional diagram tools require separate files, expensive licenses, or cloud services. Mermaid diagrams are:
- Text-based — version control friendly
- Portable — render anywhere Mermaid is supported
- Maintainable — update diagrams by editing text
- Fast — no GUI needed
Flowcharts
The most common diagram type. Use graph or flowchart to define direction:
flowchart LR
A[Start] --> B{Decision}
B -->|Yes| C[Do something]
B -->|No| D[Do something else]
C --> E[End]
D --> E
Direction options: LR (left-right), RL, TB (top-bottom), BT.
Sequence Diagrams
Perfect for documenting API calls and system interactions:
sequenceDiagram
User->>Server: GET /api/posts
Server->>Database: SELECT * FROM posts
Database-->>Server: rows[]
Server-->>User: JSON response
Gantt Charts
Visualize project timelines:
gantt
title Project Timeline
dateFormat YYYY-MM-DD
section Design
Wireframes :2024-01-01, 7d
Mockups :7d
section Development
Frontend :2024-01-15, 14d
Backend :2024-01-20, 10d
Class Diagrams
Document object-oriented designs:
classDiagram
Animal <|-- Dog
Animal <|-- Cat
Animal : +String name
Animal : +makeSound()
Dog : +fetch()
Cat : +purr()
Tips
- Use
%%for comments in your diagrams - Keep diagrams focused — one concept per diagram
- Test your syntax at the Mermaid Live Editor before embedding