PELE EDITOR

Mermaid Cheat Sheet: Syntax & Examples

Look up Mermaid syntax for flowcharts, sequence diagrams, ER models and more. Use code patterns and editable examples to build your next diagram.

Find a diagram type, compare code with its preview, then open a working example in the editor. Related templates provide complete scenarios.

Syntax essentials

  • Use stable node IDs and separate display labels. Connect nodes by ID; changing a label should not create a different node.
  • Put labels containing spaces or punctuation inside double quotes. Use the entity #quot; for a quotation mark within a label, and check the preview.
  • In flowcharts, use LR for left-to-right or TB for top-to-bottom. Label an arrow with |label|, and put a comment on its own line starting with %%.

Each diagram type has its own grammar. These examples use Pele 1.6.0; some Mermaid features and styling directives may differ. Check the preview before exporting.

Architecture Diagrams

Basic example

architecture-beta
    group app(cloud)[Pele Editor]

    service browser(internet)[Browser] in app
    service editor(server)[Editor UI] in app
    service renderer(server)[Mermaid Renderer] in app
    service file(disk)[PNG File]

    browser:R --> L:editor
    editor:R --> L:renderer
    renderer:B --> T:file
Architecture Diagrams — Basic example

Block Diagrams

Basic example

block-beta
columns 3
  Editor["Pele Editor"]:3
  Code["Code input"] Preview["Live preview"] Export["Export tools"]
  PNG["PNG"] SVG["SVG"] PDF["PDF"]
Block Diagrams — Basic example

Class Diagrams

Basic example

classDiagram
    class Diagram {
      +String code
      +String type
      +render()
    }
    class Exporter {
      +toPNG()
      +toSVG()
      +toPDF()
    }
    Diagram --> Exporter : uses
Class Diagrams — Basic example

ER Diagrams

Basic example

erDiagram
    USER ||--o{ DIAGRAM : creates
    DIAGRAM ||--o{ EXPORT : produces
    USER {
      string id
      string email
    }
    DIAGRAM {
      string id
      string mermaid_code
      string diagram_type
    }
    EXPORT {
      string id
      string format
    }
ER Diagrams — Basic example

Cardinality and keys

At a relationship endpoint, || means exactly one, o{ means zero or more, and |{ means one or more. PK, FK and UK identify primary, foreign and unique keys.

erDiagram
  CUSTOMER ||--o{ ORDER : places
  ORDER ||--|{ LINE_ITEM : contains
  CUSTOMER {
    int id PK
    string email UK
  }
  ORDER {
    int id PK
    int customer_id FK
  }
  LINE_ITEM {
    int id PK
    int order_id FK
  }
ER Diagrams — Cardinality and keys

Flowcharts

Basic example

graph TD
    A[User opens Pele Editor] --> B[Write Mermaid code]
    B --> C{Preview looks right?}
    C -- Yes --> D[Export PNG]
    C -- No --> E[Edit diagram]
    E --> B
Flowcharts — Basic example

Shapes, labels and arrows

Use square brackets for rectangles, braces for decisions, parentheses for rounded nodes, and square brackets around parentheses for database cylinders. Solid and dotted arrows can carry labels.

flowchart LR
  %% Stable IDs connect nodes; quoted labels hold display text
  A["Request (new)"] --> B{Valid?}
  B -->|Yes| C([Accepted])
  B -.->|No| D["Try again"]
  C --> E[(Database)]
Flowcharts — Shapes, labels and arrows

Groups and direction

Use subgraph and end to group related nodes. Give groups stable IDs so that their labels can change independently.

flowchart TB
  subgraph browser[Browser]
    A[Form] --> B[Submit]
  end
  subgraph server[Server]
    C[API] --> D[(Database)]
  end
  B -->|HTTPS| C
Flowcharts — Groups and direction

Gantt Charts

Basic example

gantt
    title Documentation Launch Plan
    dateFormat  YYYY-MM-DD
    section Plan
    Outline examples      :done, p1, 2026-05-01, 2d
    Review syntax         :done, p2, after p1, 1d
    section Build
    Create diagrams       :active, b1, 2026-05-04, 3d
    Publish docs          :b2, after b1, 1d
Gantt Charts — Basic example

Dependencies and milestones

Give tasks IDs and use after followed by an ID to express dependencies. A milestone has zero duration; done, active and crit mark task status. Dates here are illustrative.

gantt
  title Release plan
  dateFormat YYYY-MM-DD
  section Prepare
  Design :done, design, 2026-10-19, 2d
  Build :active, build, after design, 3d
  section Release
  Test :crit, test, after build, 2d
  Launch :milestone, launch, after test, 0d
Gantt Charts — Dependencies and milestones

Git Graphs

Basic example

gitGraph
      commit id: "docs"
      branch examples
      checkout examples
      commit id: "flowchart"
      commit id: "png"
      checkout main
      merge examples
      commit id: "publish"
Git Graphs — Basic example

User Journey

Basic example

journey
    title Pele Editor User Journey
    section Create
      Open editor: 5: User
      Paste Mermaid code: 4: User
    section Review
      Check live preview: 5: User
      Fix syntax: 3: User
    section Share
      Export PNG: 5: User
      Add to docs: 5: User
User Journey — Basic example

Kanban Boards

Basic example

kanban
  Backlog
    Add SEO examples
    Write alt text
  In Progress
    Generate PNG previews
  Done
    Build editor
    Add export tools
Kanban Boards — Basic example

Mindmaps

Basic example

mindmap
  root((Mermaid Docs))
    Diagrams
      Flowchart
      Sequence
      ERD
    Exports
      PNG
      SVG
      PDF
    SEO
      Alt text
      Code example
Mindmaps — Basic example

Packet Diagrams

Basic example

packet-beta
  0-15: "Diagram ID"
  16-31: "Export Format"
  32-63: "Image Width"
  64-95: "Image Height"
  96-127: "Alt Text Hash"
Packet Diagrams — Basic example

Pie Charts

Basic example

pie title Diagram Export Formats
    "PNG" : 45
    "SVG" : 30
    "PDF" : 15
    "JPG" : 10
Pie Charts — Basic example

Quadrant Charts

Basic example

quadrantChart
    title Diagram Content Priority
    x-axis Low effort --> High effort
    y-axis Low SEO value --> High SEO value
    quadrant-1 Plan
    quadrant-2 Invest
    quadrant-3 Skip
    quadrant-4 Automate
    Alt text: [0.2, 0.9]
    PNG preview: [0.4, 0.8]
    Code sample: [0.3, 0.95]
    Long intro: [0.8, 0.5]
Quadrant Charts — Basic example

Sankey Diagrams

Basic example

sankey-beta
Editor,PNG export,42
Editor,SVG export,28
Editor,PDF export,18
Editor,JPG export,12
PNG export,Documentation,35
SVG export,Website,22
PDF export,Presentation,15
Sankey Diagrams — Basic example

Sequence Diagrams

Basic example

sequenceDiagram
    participant User
    participant WebApp as Pele Editor
    participant Renderer
    User->>WebApp: Paste diagram code
    WebApp->>Renderer: Render Mermaid syntax
    Renderer-->>WebApp: SVG preview
    WebApp-->>User: Download PNG
Sequence Diagrams — Basic example

Conditions and loops

Use alt / else / end for alternatives and loop / end for repetition. Declare participants with aliases, then use their IDs in messages.

sequenceDiagram
  participant U as User
  participant A as API
  U->>A: Submit request
  alt Valid session
    loop Each item
      A->>A: Validate item
    end
    A-->>U: Success
  else Expired session
    A-->>U: Sign in again
  end
Sequence Diagrams — Conditions and loops

State Diagrams

Basic example

stateDiagram-v2
    [*] --> Draft
    Draft --> Preview: render
    Preview --> Editing: update code
    Preview --> Exported: download PNG
    Editing --> Preview: render again
    Exported --> [*]
State Diagrams — Basic example

Nested states

Place substates inside a state block. [*] marks an initial or final state within the surrounding scope; text after a colon labels a transition.

stateDiagram-v2
  [*] --> Idle
  Idle --> Processing: submit
  state Processing {
    [*] --> Validate
    Validate --> Save: valid
    Save --> [*]
  }
  Processing --> Complete: saved
  Complete --> [*]
State Diagrams — Nested states

Timelines

Basic example

timeline
    title Pele Editor Release Timeline
    2026-05-01 : Add example code
               : Render PNG preview
    2026-05-03 : Add image alt text
               : Improve SEO content
    2026-05-05 : Publish pages
Timelines — Basic example

XY Charts

Basic example

xychart-beta
    title "Monthly Diagram Exports"
    x-axis [Jan, Feb, Mar, Apr, May]
    y-axis "Exports" 0 --> 100
    bar [42, 58, 73, 81, 96]
    line [40, 55, 70, 84, 94]
XY Charts — Basic example

C4 architecture

Describe people, systems and their relationships with C4Context. The related templates also cover containers and components.

Basic example

C4Context
  Person(user, "User", "Uses the product")
  System(app, "Application", "Manages projects")
  System_Ext(idp, "Identity provider", "Signs users in")
  Rel(user, app, "Uses", "HTTPS")
  Rel(app, idp, "Authenticates", "OIDC")
C4 architecture — Basic example

Requirements diagram

Connect requirements to elements that verify or satisfy them. Keep requirement IDs stable so they can be traced to tests and design decisions.

Basic example

requirementDiagram
  requirement access {
    id: SEC_01
    text: "Only members can access projects"
    risk: high
    verifymethod: test
  }
  element access_test {
    type: "test"
    docref: "Membership tests"
  }
  access_test - verifies -> access
Requirements diagram — Basic example

Radar chart

Define axes first, then give each curve one value per axis in the same order. Use the same minimum and maximum for a fair comparison; values are illustrative.

Basic example

radar-beta
  axis speed["Speed"], cost["Cost"], reliability["Reliability"]
  curve a["Option A"]{4, 3, 5}
  curve b["Option B"]{3, 5, 3}
  max 5
  min 0
Radar chart — Basic example

Browse all templates ↗