Mermaid is a popular Javascript library creating SVG diagrams from text and code descriptions.

The Mermaid site offers Tutorials and good documentation.

Syntax

‍```mermaid
%%{init: { 
    "theme": "forest",
    "fontFamily": "ibm plex sans" 
}}%%
stateDiagram-v2
    [*] --> Still
    Still --> [*]
    Still --> Moving
    Moving --> Still
    Moving --> Crash
    Crash --> [*]
‍```

The diagram descriptions are formatted as code blocks with the language identifier mermaid. The example shows the code for the state diagram below.

Mermaid diagrams can change their color theme and also some attributes can be configured in a JSON preamble enclosed by %%.

Not all themes or configurable attributes are available with every type of diagram for now. We have to test our diagrams before we publish them. One good way is the official Mermaid live editor.

Layout

The following diagrams are only a few examples to give an impression of the layout. More diagram types exist and their number is growing.

State diagram

%%{init:
  { 
    "theme": "forest",
    "fontFamily": "ibm plex sans" 
  }
}%%
stateDiagram-v2
    [*] --> Still
    Still --> [*]
    Still --> Moving
    Moving --> Still
    Moving --> Crash
    Crash --> [*]

Few quips galvanized the mock jury box. Fake bugs put in wax jonquils drive him crazy. Sympathizing would fix Quaker objectives. Junk MTV quiz graced by fox whelps. The quick brown fox jumps over the lazy dog.

Jackdaws love my big sphinx of quartz. Vexed nymphs go for quick waltz job. My faxed joke won a pager in the cable TV quiz show. A wizard’s job is to vex chumps quickly in fog. Glib jocks quiz nymph to vex dwarf. Quick zephyrs blow, vexing daft Jim. Jim quickly realized that the beautiful gowns are expensive.

Vamp fox held quartz duck just by wing. Quincy Pondexter blocked five jams against the Wizards! My ex pub quiz crowd gave joyful thanks. Fake bugs put in wax jonquils drive him crazy. The quick onyx goblin jumps over the lazy dwarf. Kvetching, flummoxed by job, W. zaps Iraq.

Flow chart

%%{init:
  { 
    "theme": "base",
    "fontFamily": "ibm plex sans" 
  }
}%%
flowchart LR
    A(Start) -->|Show edges| B[Hard Edge]
    B -->|Link text| C(Round edge)
    C -->|Show decision| D{Decision}
    D -->|One| E[Result one]
    D -->|Two| F[Result two]

Entity relation

%%{init:
  { 
    "theme": "base",
    "fontFamily": "ibm plex sans" 
  }
}%%
erDiagram
    CUSTOMER }|..|{ DELIVERY-ADDRESS : has
    CUSTOMER ||--o{ ORDER : places
    CUSTOMER ||--o{ INVOICE : "liable for"
    DELIVERY-ADDRESS ||--o{ ORDER : receives
    INVOICE ||--|{ ORDER : covers
    ORDER ||--|{ ORDER-ITEM : includes
    PRODUCT-CATEGORY ||--|{ PRODUCT : contains
    PRODUCT ||--o{ ORDER-ITEM : "ordered in"