Quickly learn how to create various diagrams using Mermaid syntax
Choose a diagram below, copy its plain-text source, and select Try in Editor to preview it. For flowcharts, graph TD and flowchart TD both create a top-down layout; graph LR runs from left to right. Use node IDs to connect steps and quotes around labels containing punctuation. Paste the source without Markdown code fences.
graph TD
A[๐ Start Project] --> B{๐ Have Requirements?}
B -->|โ
Yes| C[๐ป Start Coding]
B -->|โ No| D[๐ Gather Requirements]
D --> B
C --> E{๐งช Tests Pass?}
E -->|โ
Yes| F[๐ Deploy!]
E -->|โ No| G[๐ง Fix Bugs]
G --> EBasic Syntax:
graph TD defines a top-down graph (TD = Top Down) A[Text] creates a rectangular node B{Text} creates a diamond node (condition) --> creates an arrow connection -->|Text| creates a labeled arrowsequenceDiagram participant U as ๐ค User participant S as ๐ฅ๏ธ System participant D as ๐พ Database U->>S: ๐ Submit Request S->>D: ๐ Query Data D-->>S: ๐ Return Results S-->>U: โ Display Response
Basic Syntax:
sequenceDiagram defines a sequence diagram participant Name defines a participant A->>B: Text creates a solid arrow for synchronous messages A-->>B: Text creates a dashed arrow for return/asynchronous messagesclassDiagram
class Animal {
+String name
+int age
+makeSound()
}
class Dog {
+String breed
+bark()
+fetch()
}
class Cat {
+String color
+meow()
+sleep()
}
Animal <|-- Dog
Animal <|-- CatBasic Syntax:
classDiagram defines a class diagram class ClassName {} defines a class with properties/methods + indicates public properties/methods - indicates private properties/methods A <|-- B indicates B inherits from A (B is a subclass of A)stateDiagram-v2 [*] --> Idle Idle --> Processing: Start Task Processing --> Success: Complete Processing --> Error: Failed Error --> Processing: Retry Success --> [*]
Basic Syntax:
stateDiagram-v2 defines a state diagram [*] represents the start or end state A --> B creates a transition from A to B A --> B: Text creates a labeled transitionerDiagram
USER ||--o{ ORDER : places
ORDER ||--|{ ITEM : contains
USER ||--o{ REVIEW : writes
ITEM ||--o{ REVIEW : receivesBasic Syntax:
erDiagram defines an entity relationship diagram ||--o{ represents a one-to-many relationship ||--|{ represents a one-to-many (mandatory) relationship }|..|{ represents a many-to-many relationship (dashed line) : Text defines the relationship descriptiongantt title ๐ Project Timeline dateFormat YYYY-MM-DD section Planning Requirements :done, req, 2024-01-01, 7d Design :active, des, after req, 10d section Development Coding :dev, after des, 14d Testing :test, after dev, 7d section Launch Deploy :deploy, after test, 3d
Basic Syntax:
gantt defines a Gantt chart title Title sets the chart title dateFormat Format sets the date format section Name defines a project section Task Name: ID, Start Date, Duration/End Date defines a task, its start date, and its duration or end date done/active indicates task status after ID indicates after another taskpie title ๐ Time Distribution "๐ป Coding" : 40 "๐ Debugging" : 25 "๐ Learning" : 20 "โ Coffee Break" : 15
Basic Syntax:
pie defines a pie chart title Title sets the pie chart title "Label" : Value defines a slice of the pie chartThis page provides basic Mermaid syntax guidelines. For more advanced features and detailed syntax, please refer to: