Mermaid Diagram Types
Mermaid draws many kinds of diagrams from plain text. Pick a type to open an editor that is already set up for it, with the syntax, examples and common errors below the editor. Everything renders in your browser and exports to PNG, SVG or PDF for free.
Flowchart (graph TD)
graph TD / flowchart LR Process steps, decisions and workflows. Flowcharts are drawn in the main editor, which opens with a graph TD example. Open the editor →Sequence diagramsequenceDiagramA sequence diagram shows how people and systems talk to each other over time. Each participant gets a vertical lifeline, and every message is an arrow between two lifelines, read from top to bottom.ER diagramerDiagramAn entity relationship (ER) diagram shows the tables or entities in a data model and how they relate: one-to-one, one-to-many or many-to-many. Mermaid draws the relationships with crow’s foot notation.Class diagramclassDiagramA UML class diagram shows the classes in a system, the data and methods each one has, and how they relate through inheritance, composition, aggregation and association.Gantt chartganttA Gantt chart lays project tasks out on a calendar so you can see what runs when, what depends on what, and where the deadlines are.State diagramstateDiagram-v2A state diagram describes a state machine: the states something can be in, the events that move it from one state to another, and where it starts and ends.MindmapmindmapA mind map starts from one central idea and branches out into related topics. It is useful for brainstorming, note taking and planning, because the structure grows as you think.Which diagram type should I use?
- A process or decision tree: a flowchart (graph TD), the default in the online editor.
- Messages between systems over time: sequence diagram.
- A database schema: ER diagram.
- Classes and interfaces in code: class diagram.
- The states of an order or UI component: state diagram.
- A schedule with dates and dependencies: Gantt chart.
- Brainstorming or notes: mindmap.
Each page explains the syntax with a rendered example, so you can compare the types before you commit to one.
How Mermaid knows the diagram type
The first line of the code declares the type, and everything after it follows that type's syntax. Change the first line and the rest of the code has to change too. Comments starting with %% and a front matter block for configuration may come before it.
%% The first line declares the diagram type
sequenceDiagram
Browser->>Server: GET /
Server-->>Browser: 200 OK