How to create diagrams and charts in Markdown?
Mermaid lets you create diagrams and visualizations using text and code.
Flowchart
Node shapes
Simple node
flowchart LR node
Square node
flowchart LR square[square node]
Round node
flowchart LR round(round node)
Pill node
flowchart LR stadium([pill node])
Subroutine node
flowchart LR subroutine[[subroutine node]]
Cylindrical node
flowchart LR cylindrical[(cylindrical node)]
Circular node
flowchart LR circular((circular node))
Asymmetric node
flowchart LR asymmetric>asymmetric node]
Rhombus node
flowchart LR rhombus{rhombus node}
Hexagon node
flowchart LR hexagon{{hexagon node}}
Right parallelogram node
flowchart LR parallelogram_right[/right parallelogram node/]
Left parallelogram node
flowchart LR parallelogram_left[\left parallelogram node\]
Down trapezoid node
flowchart LR trapezoid_down[/down trapezoid node\]
Up trapezoid node
flowchart LR trapezoid_up[\up trapezoid node/]
Double circular node
flowchart LR double_circular(((double circular node)))
Node Connections
Link Types
Solid link
flowchart LR A --- B
Dotted link
flowchart LR A -.- B
Thick link
flowchart LR A === B
With description
Pipe syntax
flowchart LR A --->|description| B
Between syntax
flowchart LR A --description-> B
Arrow heads
Default arrow
flowchart LR A --> B
Start arrow
flowchart LR A --o B
Close arrow
flowchart LR A --x B
Multi directional arrows
flowchart LR A <--> B C o--o D E x--x F
Subgraphs
flowchart TB subgraph one[Label] A --> B end subgraph two C --> D end one --> two
Interactions
flowchart LR A-->B B-->C C-->D click A href "http://localhost:3000" click B href "https://www.github.com"
Sequence
Syntax
Participants
sequenceDiagram participant Alice participant Bob Alice->>Bob: Hi Bob Bob->>Alice: Hi Alice
Actors
sequenceDiagram actor Alice actor Bob Alice->>Bob: Hi Bob Bob->>Alice: Hi Alice
Aliases
sequenceDiagram participant A as Alice participant J as John A->>J: Hello John, how are you? J->>A: Great!
Arrows
sequenceDiagram A->B: Solid line without arrow A-->B: Dotted line without arrow A->>B: Solid line with arrowhead A-->>B: Dotted line with arrowhead A-xB: Solid line with a cross at the end A--xB: Dotted line with a cross at the end A-)B: Solid line with an open arrow at the end (async) A--)B: Dotted line with a open arrow at the end (async)
Activations
sequenceDiagram A->>B: B activate B B->>+A: B B->>-A: B A->>B: B deactivate A
Class
Syntax
classDiagram class BankAccount BankAccount : string owner BankAccount : number balance BankAccount : deposit(amount) BankAccount : withdrawal(amount)
Visibility
classDiagram class Visibility Visibility: +string public Visibility: -string private Visibility: #string protected Visibility: ~string internal Visibility: string static$ Visibility: getStatic()$ Visibility: getAbstract()*
Relationships
classDiagram classA --|> classB : Inheritance classC --* classD : Composition classE --o classF : Aggregation classG --> classH : Association classI -- classJ : Link(Solid) classK ..> classL : Dependency classM ..|> classN : Realization classO .. classP : Link(Dashed)
Cardinality / Multiplicity on relations
classDiagram Customer "1" --> "*" Ticket Student "1" --> "1..*" Course Galaxy --> "many" Star : Contains
State
Syntax
stateDiagram-v2direction LR [*] --> stateNode: transition stateNode --> [*]
Composite
stateDiagram-v2direction LR [*] --> mainState: transition state mainState { direction LR [*] --> subState state subState { direction LR [*] --> subSubState subSubState --> [*] } subState --> [*] } mainState --> [*]
Choice
stateDiagram-v2 state choice <<choice>> [*] --> condition condition --> choice choice --> false choice --> true
Forks
stateDiagram-v2 state fork <<fork>> state join <<join>> [*] --> fork fork --> A fork --> B A --> join B --> join join --> [*]
Notes
stateDiagram-v2 State1: The state with a note note right of State1 Important information! You can write notes. end note State1 --> State2 note left of State2 : This is the note to the left.
Concurrency
stateDiagram-v2direction LR[*] --> concurrencystate concurrency { direction TB [*] --> stateNode1: transition stateNode1 --> [*] -- direction TB [*] --> stateNode2: transition stateNode2 --> [*]}concurrency --> [*]
Entity Relationship
Syntax
erDiagram CAR ||--o{ NAMED-DRIVER : allows PERSON ||--o{ NAMED-DRIVER : is
Relationships
One
erDiagram one ||--|| to-one : relationship
Zero or one
erDiagram zero-one |o--o| to-zero-one : relationship
Zero or more
erDiagram zero-more }o--o{ to-zero-more : relationship
One or more
erDiagram one-more }|--|{ to-one-more : relationship
Attributes
erDiagram CAR ||--o{ NAMED-DRIVER : allows CAR { string registrationNumber string make string model } PERSON ||--o{ NAMED-DRIVER : is PERSON { string firstName string lastName int age }
User Journey
journey title My working day section Go to work Make tea: 5: Me Go upstairs: 3: Me Do work: 1: Me, Cat section Go home Go downstairs: 5: Me Sit down: 5: Me
Gantt
Syntax
gantt default :a, 2022-10-08, 1w critical :crit, b, 2022-10-08, 1d active :active, c, after b a, 1d critical active :crit, active, ca, after c, 1d milestone : milestone, m1, 17:49, 2min milestone : milestone, m2, 18:14, 1d
Pie chart
pie showData title Key elements in Product X "Calcium" : 42.96 "Potassium" : 50.05 "Magnesium" : 10.01 "Iron" : 5
Requirement
Syntax
requirementDiagram requirement test_req { id: 1 text: the test text. risk: high verifymethod: test } element test_entity { type: simulation } test_entity - satisfies -> test_req
Requirement
requirementDiagram requirement test_req { id: 1 text: the test text. risk: high verifymethod: test }
Types:
- requirement
- functionalRequirement
- interfaceRequirement
- performanceRequirement
- physicalRequirement
- designConstraint
Risk:
- Low
- Medium
- High
Verification Method:
- Analysis
- Inspection
- Test
- Demonstration
Gitgraph
%%{ init: { 'logLevel': 'debug', 'theme': 'dark' } }%%gitGraph commit id: "initial commit"
branch hom branch feat/button
checkout feat/button commit id: "create button" commit id: "finish button"
checkout hom merge feat/button
checkout feat/button commit id: "fix hover"
checkout hom merge feat/button
checkout feat/button commit id: "fix accessibility"
checkout hom merge feat/button
checkout main merge hom