Mermaid diagrams

Lineout converts Mermaid flowcharts, sequence diagrams, state diagrams and use case diagrams into ordinary shapes, groups, frames and arrows, laid out automatically. The conversion happens once: the result is a page you edit like any other.

flowchart LR
  user([User]) --> api[API Gateway]
  api -->|invoke| fn[Lambda]
  fn --> db[(Orders)]

Bringing a diagram in#

WhereHow
CanvasPaste the text. If it can't be read, a dialog shows the line to fix. See Copy and paste.
Code panelAdd from Mermaid… adds it to the current page. See Code panel.
Command paletteNew page from Mermaid adds it as a page, named after its title.
DashboardDrop .mmd or .mermaid files on a project. See Importing diagrams.
MCPcreate_diagram and add_page accept Mermaid text. See Mermaid content.

Every diagram can start with a frontmatter title, which names the page. %% comments, %%{init: …}%% directives and a surrounding mermaid code fence are ignored. Other kinds of Mermaid diagrams, such as class or entity relationship diagrams, aren't supported.

Flowcharts#

A flowchart starts with flowchart or graph and a direction: TB or TD, top to bottom by default, BT, LR or RL. click, accTitle and accDescr lines are skipped.

Nodes#

A node's text comes from its brackets or from label: in its shape data, else from its id. <br> starts a new line, and entity codes such as #quot; are decoded.

MermaidLineout
A[Text], A[[Text]], A>Text]Rectangle
A(Text), A([Text])Rounded rectangle
A((Text)), A(((Text)))Circle
A{Text}Diamond
A{{Text}}Hexagon
A[(Text)]Cylinder
A[/Text/], A[\Text\]Parallelogram
A[/Text\], A[\Text/]Rectangle
A@{ shape: tri, label: "Text" }The shape in the table below
A@{ icon: "AWS-Lambda", label: "Text" }Icon node

Shape data names every Mermaid shape, and several map to the same Lineout shape:

LineoutMermaid shape names
Rectanglerect, fr-rect, notch-rect, lin-rect, div-rect, st-rect, tag-rect, sl-rect, bow-rect, win-pane, doc, lin-doc, docs, tag-doc, flag, odd, curv-trap, trap-t, trap-b, bolt, datastore, folder, browser, console, cloud, bang
Rounded rectanglerounded, stadium, delay
Circlecircle, dbl-circ
Filled circlesm-circ, f-circ
Bullseyefr-circ
Crossed circlecross-circ
Diamonddiam
Hexagonhex
Cylindercyl, h-cyl, lin-cyl, bucket
Parallelogramlean-r, lean-l
Triangletri, flip-tri
Pentagonnotch-pent
Hourglasshourglass
Barfork
Actorperson
Text nodetext, brace, brace-r, braces
  • Shapes are sized to fit their text. The filled circle, bullseye, crossed circle, bar and hourglass show a label under the shape, and only one set with label:.
  • person becomes an actor, a stick figure with its text under it.
  • icon is a Lineout icon name, such as AWS-Lambda or Generic_Router, or an icon pack name such as logos:aws-lambda, which is matched to Lineout's icons. An unknown icon becomes a rounded rectangle.

Subgraphs#

Each subgraph … end becomes a group around its nodes, and subgraphs nest. subgraph vpc [Production network] gives the group the id vpc and the title "Production network". Its corner icon comes from:

  1. A vpc@{ icon: "Virtual-private-cloud-VPC" } line, a Lineout extension that Mermaid itself doesn't support.
  2. A title that names a group icon, such as "AWS Cloud", "Region", "VPC", "Private subnet" or "Data center".
  3. Otherwise, a plain grey group.

Cost estimates only count services inside an AWS Cloud group, so title a subgraph "AWS Cloud" to get an estimate.

A direction inside a subgraph applies when the subgraph holds no other subgraphs and none of its nodes link outside it. Otherwise it follows the flowchart's direction, as in Mermaid.

MermaidLineout
A --> BArrow
A --- BLine without an arrowhead
A <--> BArrowheads at both ends
A --x BArrow with a cross
A --o BArrow, since Lineout has no circle head
A -.-> BDashed arrow
A ==> BThicker arrow
A ~~~ BNo arrow, but B is placed after A
A -->|HTTPS| B, A -- HTTPS --> BLabeled arrow

Chains such as A --> B --> C and A & B --> C & D make an arrow for every pair, and extra dashes, as in A ---> B, add room between the nodes. A link to a subgraph's id attaches to the group. Arrows that pass other nodes get pinned routes. See Routes.

Styles#

style, classDef, class, A:::className and linkStyle carry over:

PropertyLineout
fillFill of a shape or group
strokeBorder color, or line color for links
stroke-widthBorder or line width
stroke-dasharrayDashed border or line
colorText color
font-weight, font-styleBold and italic text

Colors can be hex, rgb(), Lineout palette names such as red, or common CSS names such as navy, which become the closest palette color. Other properties are ignored. State and use case diagrams take the same styles.

Activity diagrams#

A UML activity diagram is a flowchart with UML shapes: start for the initial node, stop for the final node, fork or join for bars across the flow, cross-circ for a flow final and hourglass for a time event, with A{Decision} for decisions and merges.

flowchart TB
  start@{ shape: start } --> receive([Receive order]) --> stock{In stock?}
  stock -->|yes| fork@{ shape: fork }
  stock -->|no| cancel@{ shape: cross-circ, label: "Cancelled" }
  fork --> ship[Ship] --> join@{ shape: join }
  fork --> bill[Bill] --> join
  join --> stop@{ shape: stop }

Sequence diagrams#

sequenceDiagram becomes lifelines side by side, with a row per message. A title line names the page.

MermaidLineout
participant A as Web app, actor U as UserBox and actor lifelines, in order. Undeclared participants are added as they appear, and ids become node ids.
A->>B, A-->>B, A-)B, A-xB, A->B, A-->B, A<<->>BFilled head, dashed, open head, cross, no head, dashed without head, both ends.
A->>+B, activate B … B-->>-A, deactivate BActivation bars, with nested ones a little to the right.
loop, alt/else, opt, par/and, critical/option, break … endCombined fragments with their operator, condition and dividers.
rect rgb(…) … endA filled frame.
Note right of A, Note left of A, Note over A,BNotes.
create participant B, destroy BA lifeline that starts at its creating message, or ends with a cross.
box Purple Team … endA frame named "Team", filled with the closest palette color.

Messages to the sender loop back to its lifeline, autonumber numbers the messages, and arrows are named m1, m2 and so on. link, links, properties, details, accTitle and accDescr lines are skipped.

State diagrams#

stateDiagram-v2 or stateDiagram reads top to bottom unless it sets a direction.

MermaidLineout
A --> B: eventA transition.
[*] --> A, A --> [*]Initial and final states, one of each per composite state.
state "Long name" as A, A: descriptionThe state's text.
state C <<choice>>, <<fork>>, <<join>>A small diamond, and bars.
state Composite { … }, with -- between partsA composite state with rounded corners, split into concurrent regions.
note right of A: text, or note left of A … end noteA note linked to the state with a dashed line.

classDef, class, A:::className and style apply the styles above.

Use case diagrams#

usecase-beta, which Mermaid still marks as beta, reads left to right unless it sets a direction.

MermaidLineout
actor Customer, actor Admin("Administrator")Actors.
Login("Sign in"), "Reset password"Use cases. Anything a relationship names that isn't declared too.
Report[Generate report], json nodesRectangles.
systemBoundary shop["Online shop"] … endA frame around its use cases, with a tab for @{ type: package }.
Customer --> Login, A --- B, A <-- BAssociations, with a head, without one, or pointing back.
Checkout ..> : include Payment, Coupon ..> : extend CheckoutDashed arrows with open heads, labeled «include» and «extend».
Admin --|> PersonA generalization with a hollow head.
A -- "label" --> BA labeled association.
note for Login "text"A note linked to the use case.

Stereotypes such as <<Core>> are added above the name.

Limits#

LimitValue
Nodes500
Links, transitions, relationships or messages1000
Text200,000 characters

Lineout also refuses a diagram whose layout would be too much work, with "the diagram is too large to lay out". This happens when many links skip across hundreds of nodes, or when many subgraphs nest around a long chain: split such a diagram up. The same text always gives the same page, wherever it comes from.