8000 GitHub - JakeSteam/Mermaid: A regularly updated collection of cheatsheets for using Mermaid diagrams on GitHub and elsewhere
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

A regularly updated collection of cheatsheets for using Mermaid diagrams on GitHub and elsewhere

License

Notifications You must be signed in to change notification settings

JakeSteam/Mermaid

Repository files navigation

Tip

Last updated Apr 2025 to include Quadrant, C4, Mindmap, ZenUML, Timeline, Sankey, XY, Block, Architecture, Kanban, Packet, and Radar diagrams!

Mermaid syntax references

A rewrite of the Mermaid documentation as a learning aid and cheatsheet. You can also experiment with Mermaid in their interactive online editor!

ExampleCode
flowchart LR
    A[Start] --> B{Should you?}
    B -- Yes --> C{{Do it}}
    B -- Maybe --> D[(Save for later)]
    B -- No --> E[Okay]
Loading
flowchart LR
    A[Start] --> B{Should you?}
    B -- Yes --> C{{Do it}}
    B -- Maybe --> D[(Save for later)]
    B -- No --> E[Okay]

Flowchart in Mermaid cheatsheet

sequenceDiagram
    Alice ->>+ Bob: Here's a message!
    Bob ->>- Alice: Hmm, ok, thanks.
Loading
sequenceDiagram
    Alice ->>+ Bob: Here's a message!
    Bob ->>- Alice: Hmm, ok, thanks.

Sequence diagram in Mermaid cheatsheet

classDiagram
    class ClassName {
        String stringName
        Long longName
        MyDatatype attributeName

        functionName(parameter) ReturnType
        functionName2(parameter2) ReturnType
    }
    class Interface {
        Int intName
    }
    ClassName --|> Interface
Loading
classDiagram
    class ClassName {
        String stringName
        Long longName
        MyDatatype attributeName

        functionName(parameter) ReturnType
        functionName2(parameter2) ReturnType
    }
    class Interface {
        Int intName
    }
    ClassName --|> Interface

Class diagram in Mermaid cheatsheet

stateDiagram-v2
    Stationary --> Moving : Begin moving
    Moving --> Stationary : Stop moving
Loading
stateDiagram-v2
    Stationary --> Moving : Begin moving
    Moving --> Stationary : Stop moving

State diagram in Mermaid cheatsheet

erDiagram
    User {
        Int id PK
        String username
        Int serverId FK
    }

    Server {
        Int id PK
        String serverName
    }

    Server ||--o{ User : has
Loading
erDiagram
    User {
        Int id PK
        String username
        Int serverId FK
    }

    Server {
        Int id PK
        String serverName
    }

    Server ||--o{ User : has

Entity relationship diagram in Mermaid cheatsheet

journey
    title User Journey
    section Logging in
        Navigate to login: 4: Alice, Bob, Craig
        Entering details: 2: Alice, Bob
        Pressing button: 5: Alice
Loading
journey
    title User Journey
    section Logging in
        Navigate to login: 4: Alice, Bob, Craig
        Entering details: 2: Alice, Bob
        Pressing button: 5: Alice

User journey diagram in Mermaid cheatsheet

gantt
    Dated Milestone: milestone, m1, 2023-01-01, 1d
    Relative Milestone: milestone, m2, after m1, 1d
    Task 1: a1, 2023-01-01, 1d
    Task 2: a2, after a1, 1d
    Task 3: a3, 2023-01-01, 36hr
Loading
gantt
    Dated Milestone: milestone, m1, 2023-01-01, 1d
    Relative Milestone: milestone, m2, after m1, 1d
    Task 1: a1, 2023-01-01, 1d
    Task 2: a2, after a1, 1d
    Task 3: a3, 2023-01-01, 36hr

Gantt chart in Mermaid cheatsheet

pie
    title Fruits
    "Apples" : 50
    "Oranges" : 20
    "Grapes" : 9.99
    "Passionfruits" : 12.5
Loading
pie
    title Fruits
    "Apples" : 50
    "Oranges" : 20
    "Grapes" : 9.99
    "Passionfruits" : 12.5

Pie chart in Mermaid cheatsheet

quadrantChart
    title Title of quadrant chart
    x-axis X low value --> X high value
    y-axis Y low value --> Y high value
    quadrant-1 Top right name
    quadrant-2 Top left name
    quadrant-3 Bottom left name
    quadrant-4 Bottom right name
    Value A: [0.1, 0.2]
    Value B: [0.9, 0.8]
    Value C: [0.5, 0.5]
    Value D: [0.9, 0.9]
Loading
quadrantChart
    title Title of quadrant chart
    x-axis X low value --> X high value
    y-axis Y low value --> Y high value
    quadrant-1 Top right name
    quadrant-2 Top left name
    quadrant-3 Bottom left name
    quadrant-4 Bottom right name
    Value A: [0.1, 0.2]
    Value B: [0.9, 0.8]
    Value C: [0.5, 0.5]
    Value D: [0.9, 0.9]

Quadrant diagram in Mermaid cheatsheet

    requirementDiagram

    requirement UptimeRequirement {
        id: 1
        text: Site Uptime
        risk: Medium
        verifymethod: Analysis
    }

    element satisfyingElement {
        type: MyElement
        docref: ABC001
    }

    element containingElement {
        type: MyElement
        docref: ABC002
    }

    satisfyingElement - satisfies -> UptimeRequirement
    containingElement - contains -> UptimeRequirement
Loading
    requirementDiagram

    requirement UptimeRequirement {
        id: 1
        text: Site Uptime
        risk: Medium
        verifymethod: Analysis
    }

    element satisfyingElement {
        type: MyElement
        docref: ABC001
    }

    element containingElement {
        type: MyElement
        docref: ABC002
    }

    satisfyingElement - satisfies -> UptimeRequirement
    containingElement - contains -> UptimeRequirement

Requirement diagram in Mermaid cheatsheet

gitGraph:
    commit
    branch branch2
    checkout branch2
    commit
    checkout main
    commit
    merge branch2
Loading
gitGraph:
    commit
    branch branch2
    checkout branch2
    commit
    checkout main
    commit
    merge branch2

Git graphs in Mermaid cheatsheet

C4Dynamic
    title Internet Banking System Application

    ContainerDb(c4, "Database", "Schema", "Stores")
    Container(c1, "SPA", "JS", "Banking.")
    Container_Boundary(b, "API Application") {
      Component(c3, "Security", "Bean", "Login.")
      Component(c2, "Controller", "Controller", "A")
    }
    Rel(c1, c2, "Submits", "JSON/HTTPS")
    Rel(c2, c3, "Calls isAuthenticated() on")
    Rel(c3, c4, "select *", "JDBC")
Loading
C4Dynamic
    title Internet Banking System Application

    ContainerDb(c4, "Database", "Schema", "Stores")
    Container(c1, "SPA", "JS", "Banking.")
    Container_Boundary(b, "API Application") {
      Component(c3, "Security", "Bean", "Login.")
      Component(c2, "Controller", "Controller", "A")
    }
    Rel(c1, c2, "Submits", "JSON/HTTPS")
    Rel(c2, c3, "Calls isAuthenticated() on")
    Rel(c3, c4, "select *", "JDBC")

C4 diagram in Mermaid cheatsheet

mindmap
    Middle element
        Branch 1
        Branch 2
        Branch 3
        Branch 4
            Sub-branch 1
            Sub-branch 2
            Sub-branch 3
                Sub-sub-branch 1
Loading
mindmap
    Middle element
        Branch 1
        Branch 2
        Branch 3
        Branch 4
            Sub-branch 1
            Sub-branch 2
            Sub-branch 3
                Sub-sub-branch 1

Mindmaps diagram in Mermaid cheatsheet

timeline
    title Timeline title
    2001: Something happened
    2002: Something else happened
    2003: Another thing happened
    Whenever: This happened!
            : And this!
Loading
timeline
    title Timeline title
    2001: Something happened
    2002: Something else happened
    2003: Another thing happened
    Whenever: This happened!
            : And this!

Timeline diagram in Mermaid cheatsheet

Will not work within GitHub without additional configuration.

zenuml
    @Actor "An actor"
    @VirtualMachine "A virtual machine"
    @GoogleSecurity "Google Security"
    @S3 "S3 bucket"
    "An actor"->"A virtual machine": Uses
    "A virtual machine"->"Google Security": Logs in
    "Google Security"->"S3 bucket": Stores data

ZenUML diagram in Mermaid cheatsheet

sankey-beta
    BlockA,SubblockA,100
    BlockA,SubblockB,50
    BlockA,SubblockC,10
    SubblockA,SubsubblockA,70
    SubblockA,SubsubblockC,30
    SubblockB,SubsubblockA,50
    SubblockC,SubsubblockB,7
    SubblockC,SubsubblockD,80
    BlockB,SubsubblockD,20
Loading
sankey-beta
    BlockA,SubblockA,100
    BlockA,SubblockB,50
    BlockA,SubblockC,10
    SubblockA,SubsubblockA,70
    SubblockA,SubsubblockC,30
    SubblockB,SubsubblockA,50
    SubblockC,SubsubblockB,7
    SubblockC,SubsubblockD,80
    BlockB,SubsubblockD,20

Sankey diagram in Mermaid cheatsheet

xychart-beta
    title "Chart title"
    x-axis "Some months" [January, Febuary, March]
    y-axis "How much I like them" 0.0 --> 1.0
    bar [0.3, 0.1, 0.4]
    line [5000, 6000, 7500]
Loading
xychart-beta
    title "Chart title"
    x-axis "Some months" [January, Febuary, March]
    y-axis "How much I like them" 0.0 --> 1.0
    bar [0.3, 0.1, 0.4]
    line [5000, 6000, 7500]

XY diagram in Mermaid cheatsheet

block-beta
    columns 5
    a:3 b:2 c d e f g h
    block:myBlock:2
        columns 2
        i j k
    end
Loading
block-beta
    columns 5
    a:3 b:2 c d e f g h
    block:myBlock:2
        columns 2
        i j k
    end

Block diagram in Mermaid cheatsheet

packet-beta
    title Packet diagram title
    0-5: "First bytes"
    6-15: "More bytes"
    16-31: "Many more!"
    32-63: "A defined row"
    64-93: "Almost full row"
    94: "A"
    95: "B"
Loading
packet-beta
    title Packet diagram title
    0-5: "First bytes"
    6-15: "More bytes"
    16-31: "Many more!"
    32-63: "A defined row"
    64-93: "Almost full row"
    94: "A"
    95: "B"

Packet diagram in Mermaid cheatsheet

kanban
    Individual metadata
        Task B@{ ticket: ABC-123 }
        Task C@{ assigned: 'Jake' }
        Task D@{ priority: 'High' }
    Combined metadata
        Task A@{ ticket: ABC, assigned: 'J', priority: 'High' }
    All priorities
        Very High@{ priority: 'Very High' }
        High@{ priority: 'High' }
        Default
        Low@{ priority: 'Low' }
        Very Low@{ priority: 'Very Low' }
Loading
kanban
    Individual metadata
        Task B@{ ticket: ABC-123 }
        Task C@{ assigned: 'Jake' }
        Task D@{ priority: 'High' }
    Combined metadata
        Task A@{ ticket: ABC, assigned: 'J', priority: 'High' }
    All priorities
        Very High@{ priority: 'Very High' }
        High@{ priority: 'High' }
        Default
        Low@{ priority: 'Low' }
        Very Low@{ priority: 'Very Low' }

Kanban diagram in Mermaid cheatsheet

architecture-beta
    service db(database)[Database]
    service disk1(disk)[Storage]
    service disk2(disk)[Storage]
    service server(server)[Server]

    db:L <-- R:server
    disk1:T -- B:server
    disk2:T <-- B:db
Loading
architecture-beta
    service db(database)[Database]
    service disk1(disk)[Storage]
    service disk2(disk)[Storage]
    service server(server)[Server]

    db:L <-- R:server
    disk1:T -- B:server
    disk2:T <-- B:db

Architecture diagram in Mermaid cheatsheet

radar-beta
    title Language skills
    axis English, French, German, Spanish, Dutch, Abc, Def
    curve a["User1"]{20, 30, 50, 60, 80, 30, 30}
    curve b["User2"]{80, 30, 40, 50, 90, 10, 20}
    curve c["User3"]{100, 100, 30, 50, 70, 70, 40}
Loading
radar-beta
    title Language skills
    axis English, French, German, Spanish, Dutch, Abc, Def
    curve a["User1"]{20, 30, 50, 60, 80, 30, 30}
    curve b["User2"]{80, 30, 40, 50, 90, 10, 20}
    curve c["User3"]{100, 100, 30, 50, 70, 70, 40}

Radar diagram in Mermaid cheatsheet

About

A regularly updated collection of cheatsheets for using Mermaid diagrams on GitHub and elsewhere

Topics

Resources

License

Stars

Watchers

Forks

0