Register
Process Type
Graphical expression
Mind Type
Structured expression
Note Type
Efficient expression

Mermaid Online Editor - Generate flowcharts, sequence diagrams, class diagrams, and 21 diagram types in total from Mermaid syntax

Wendy , ProcessOn Community Operations Director
2026-10-16
35
facebook x

Mermaid is a tool that generates diagrams from text-based syntax. By writing simple Mermaid code, you can create flowcharts, sequence diagrams, class diagrams, state diagrams, ER diagrams, Gantt charts, mind maps, architecture diagrams, and many other diagram types.

Unlike traditional drag-and-drop drawing tools, Mermaid describes the nodes, relationships, chronological order, and data structures in a diagram mainly through code. When you change the code, the diagram is regenerated automatically, which makes Mermaid especially well suited to technical documentation, product design, project management, software development, and knowledge organization.

This article introduces Mermaid's basic syntax and rounds up the Mermaid diagram types that the editor can render, together with their declaration syntax, code examples, and use cases. If you want to write and preview Mermaid code online, you can try the free ProcessOn Mermaid Online Editor.

What is Mermaid?

Mermaid is a tool that generates diagrams using text syntax. The code below generates a simple Mermaid flowchart:

flowchart TD

A[Start] --> B[Enter information]

B --> C{ Completed?}

C -->|Yes| D[End]

C -->|No| B

The rendering result is as follows:

Here: flowchart TD declares a flowchart arranged from top to bottom.

Mermaid's operating logic can be summarized as:

Write Mermaid code → parse the code → render the diagram → modify the code → the diagram updates in real time

So one of the keys to learning Mermaid is understanding the declaration syntax used by each diagram type.

Which diagram types does Mermaid support?

Different diagram types use different Mermaid declaration syntax, and the most common Mermaid diagrams include:

Diagram typeMermaid declaration syntaxCommon uses
FlowchartflowchartBusiness processes, algorithms, workflows
Sequence diagramsequenceDiagramSystem interactions, API calls
Class diagramclassDiagramSoftware structure, object-oriented modeling
State diagramstateDiagram-v2State transitions, state machines
ER diagramerDiagramDatabase entity relationships
Gantt chartganttProject planning, task progress
User journey diagramjourneyUser experience, customer journeys
Mind mapmindmapKnowledge organization, brainstorming
TimelinetimelineTimelines, historical events
Pie chartpieProportions, composition analysis
Quadrant chartquadrantChartClassification, prioritization, positioning analysis
Git graphgitGraphGit branches, commits, merges
Sankey diagramsankey-betaData, resource, and traffic flows
XY chartxychart-betaData trends, value comparisons
Radar chartradarMulti-dimensional metric comparison
C4 diagramC4Context, etc.Software architecture modeling
Architecture diagramarchitecture-betaSystem, service, and resource architecture
Kanban diagramkanbanTask and work status management
Block diagramblock-betaModule, structural, and system relationships
Packet diagrampacket-betaNetwork packet structure
Requirement diagramrequirementDiagramRequirements analysis and requirement relationships


Different Mermaid editor versions may support different syntax and features for diagrams, so in practice you should go by the syntax that your editor supports.

Mermaid flowchart

Basic syntax

Mermaid uses the flowchart declaration to create a flowchart. The simplest form is:

flowchart TD

A[Start] --> B[Arrange]

B --> C[End]

render Result

Where:

  • flowchart: declares a flowchart
  • TD: lays the diagram out from top to bottom
  • A[Start]: creates a node
  • -->: creates a line with an arrow

Mermaid flowcharts can also use LR (left to right), RL (right to left), BT (bottom to top) and other direction settings. For example:

flowchart LR

A[Start] --> B[Arrange] --> C[End]

means Flowchart it is laid out from left to right.

Common syntax

SyntaxdiagramsMeaning
(text)Rounded rectangleRepresents the start, end, or a general operation of a process
[text]RectangleRepresents a specific step, task, or processing operation
{text}DiamondRepresents a decision or conditional branch
((text))CircleRepresents a connection point or event
[[text]]Double rectangleRepresents a call to a subprocess or submodule
[(text)]CylinderRepresents a database node
>text]Asymmetric shapeRepresents input/output
[/text/]ParallelogramRepresents input or output data
-->ArrowRepresents the direction of the process
---Line without an arrowRepresents an association relationship
-.->Dashed arrowRepresents an optional flow or a reference relationship
==>Thick arrowRepresents a key flow or a strong association

For the detailed syntax for generating flowcharts with Mermaid, see the page below: https://www.processon.io/mermaid/flowchart

Flowcharts are well suited to business processes, workflows, algorithm flows, system flows, and decision flows, and you can try Mermaid Online Flowchart Editor.

Mermaid sequence diagram

Basic syntax

Mermaid uses the sequenceDiagram declaration to create a sequence diagram. The simplest example is:

sequenceDiagram

Alice->>John: Hello John

John-->>Alice: Hello Alice

Rendering result

Where:

  • sequenceDiagram: creates a Mermaid sequence diagram
  • ->>: solid arrow, represents an asynchronous message call
  • -->>: dashed arrow, represents an asynchronous response or return message

Common syntax

SyntaxdiagramsMeaning
sequenceDiagramSequence diagramCreate a sequence diagram
A->B: messageSolid lineRepresents a synchronous message call or an ordinary interaction
A-->B: messageDashed lineRepresents a return message or a weakly associated interaction
A->>B: messageSolid arrowrepresents an asynchronous message call
A-->>B: messageDashed arrowrepresents an asynchronous response or return message
participant AParticipantDefines the objects, roles, or systems involved in the interaction
actor AActorRepresents an active participant such as a user or an external system
activate AActivation boxRepresents an object starting to process a request
deactivate AEnd activationRepresents an object finishing its current processing
loop textLoop boxRepresents a repeatedly executed interaction
alt textConditional branchRepresents interaction paths under different conditions
opt textOptional flowRepresents an interaction that may be executed
par textParallel boxRepresents multiple operations executing at the same time

For the detailed syntax for generating sequence diagrams with Mermaid, see the page below: https://www.processon.io/mermaid/sequence-diagram

Sequence diagrams are well suited to describing interactions that take place in chronological order between users and systems, between systems, or between services, and you can try Mermaid sequence diagram online editor.

Mermaid class diagram

Basic syntax

Mermaid uses the classDiagram declaration to create a class diagram.

classDiagram

Animal <|-- Duck

Animal <|-- Fish

class Animal {

+String name

+eat()

}

class Duck {

+swim()

}

Rendering result

Where:

  • classDiagram: creates a Mermaid class diagram
  • <|--: Represents an inheritance relationship
  • +String name: Represents a public attribute or method

Common syntax

SyntaxdiagramsMeaning
classDiagramClass diagramCreate a class diagram
class ClassNameClassDefines a class object
ClassName : attributeAttributeRepresents a member variable of a class
ClassName : method()MethodDefines a class method
<|--Hollow triangle+ Solid lineRepresents an inheritance relationship
<|..Hollow triangle+ Dashed lineRepresents an implementation relationship
*--Filled diamond+ Solid lineRepresents a composition relationship
o--Hollow diamond+ Solid lineRepresents an aggregation relationship
-->Solid arrowRepresents an association relationship
..>Dashed arrowRepresents a dependency relationship
--Solid lineRepresents a plain connection relationship
+attributePlus signRepresents a public attribute or method
-attributeMinus signRepresents a private attribute or method

Symbols such as +, -, and # in front of class members indicate different levels of visibility.

For the detailed syntax for generating class diagrams with Mermaid, see the page below: https://www.processon.io/mermaid/class-diagram

Class diagrams are well suited to software design, object-oriented modeling, program structure analysis, and similar scenarios, and you can try Mermaid Class diagram the online editor.

Mermaid state diagram

Basic syntax

Mermaid uses the stateDiagram-v2 declaration to create a state diagram.

stateDiagram-v2

state "Pending Payment" as Pending

[*] --> Pending

Pending --> Paid

Paid --> Shipped

Shipped --> Completed

Completed--> [*]

Rendering result

Where:

  • stateDiagram-v2: creates a Mermaid state diagram
  • [*] -->: Represents entering the first state
  • -->: Represents a state transition
  • --> [*]: Represents the end of the state flow

Common syntax

SyntaxdiagramsMeaning
stateDiagram-v2State diagramCreate a state diagram
state StateNameRounded rectangleDefines a basic state node
state StateName : textRounded rectangle with textAttaches descriptive text to a state
[*]Filled dot or double circleRepresents the start or end of a state
[*] --> StateNameStart arrowRepresents entering the first state
StateName --> [*]End arrowRepresents the end of the state flow
A --> BSolid arrowRepresents a state transition
A --> B: eventSolid arrow with a labelA state transition with a triggering event
state StateName { ... }Nested rounded rectangleDefines a composite state
state Node <<choice>>DiamondBranch/decision selection node
state Fork <<fork>>Thick horizontal dividerRepresents the start of a parallel flow
state Join <<join>>Thick horizontal dividerRepresents the end and merge of a parallel flow

For the detailed syntax for generating state diagrams with Mermaid, see the page below: https://www.processon.io/mermaid/state-diagram

State diagrams are well suited to representing order states, workflow states, user states, system states, and state machines, and you can try Mermaid State diagram the online editor.

Mermaid ER the diagram

Basic syntax

Mermaid uses the erDiagram declaration to create an entity relationship diagram, also known as an ER diagram.

erDiagram

USER ||--o{ ORDER : places

ORDER ||--|{ PRODUCT : contains

Rendering result

Where:

  • erDiagram: creates a Mermaid ER diagram
  • ||--o{: One-to-many connection, Represents one entity corresponding to multiple entities, optional
  • ||--|{: One-to-many connection, Represents one entity corresponding to multiple entities, at least 1

Common syntax

SyntaxdiagramsMeaning
erDiagramER the diagramCreate a ER the diagram
ENTITY { }RectangleDefines an entity
type fieldAttribute markerDefines an entity attribute
type field PKPrimary keyDefines an entity primary key
type field FKForeign keyDefines an entity foreign key
type field UKUnique keyDefines a unique constraint field
||OneExactly one
o|Zero or oneZero or one
|{One or moreAt least one
o{Zero, one, or moreZero or more

For the detailed syntax for generating ER diagrams with Mermaid, see the page below: https://www.processon.io/mermaid/er-diagram

ER diagrams can represent entities, attributes, and the relationships between entities, and are commonly used in database design, and you can try Mermaid online ER diagram editor.

Mermaid mind map syntax

Basic syntax

Mermaid uses the mindmap declaration to create a mind map.

mindmap

root((Mermaid))

Flowchart

Sequence diagram

Class diagram

Gantt chart

Mind map

Rendering result

Where:

  • Mindmap: creates a Mermaid mind map
  • root(()): creates circle root topic

Common syntax

SyntaxdiagramsMeaning
mindmapMind mapCreate a mind map
root[text]Rectanglerectangle root topic
root(text)Rounded rectanglerounded rectangle root topic
root((text))Circlecircle root topic
root{{text}}Hexagonhexagon root topic
root)text(Bubblebubble root topic
[text]RectangleRectangle node
(text)Rounded rectangleRounded rectangle node
((text))CircleCircle node
{{text}}HexagonHexagon node
)text(BubbleBubble node

For the detailed syntax for generating mind maps with Mermaid, see the page below: https://www.processon.io/mermaid/mindmap

Mind maps express hierarchy mainly through indentation, so they are ideal for knowledge organization, brainstorming, course notes, and information architecture, and you can try Mermaid online Mind map editor.

Mermaid Gantt chart

Basic syntax

Mermaid uses the gantt declaration to create a Gantt chart.

gantt

title Project Plan

dateFormat YYYY-MM-DD

section Design

Requirements Analysis:a1, 2026-01-01, 3d

UI Design:after a1, 2d

section Development

Front-end Development:2026-01-06, 4d

Back-end Development:2026-01-07, 4d

Rendering result

Where:

  • gantt: creates a Mermaid Gantt chart
  • title: sets the Gantt chart title
  • dateFormat: defines the date parsing format for the timeline
  • section Design: represents different task groups

Common syntax

SyntaxdiagramsMeaning
ganttGantt chartCreate a Gantt chart
title textTitleSets the Gantt chart title
dateFormat textDate configuration identifierDefines the date parsing format for the timeline
section textGrouped color-block header rowDivides task groups
TaskName : id, startDate, endDateHorizontal task barDefines the task's properties
startDateHorizontal task barDefines the start time
endDateHorizontal task barDefines the end time
durationHorizontal task barDefines the task duration
idCustomDefines the task ID
after idHorizontal task barDefines a task that starts after its predecessor
16d, 2wHorizontal task barRepresents days or weeks
milestone, dateFilled diamondSets a milestone marker

For the detailed syntax for generating Gantt charts with Mermaid, see the page below: https://www.processon.io/mermaid/gantt

Mermaid Gantt charts are well suited to project planning, task scheduling, development progress, and project management, and you can try Mermaid online Gantt chart editor.

Mermaid user journey diagram

Basic syntax

Mermaid uses the journey declaration to create a user journey diagram.

journey

title User purchases a product

section Browse

Search for products: 5: User

View details: 4: User

section Place order

Add to cart: 5: User

Complete payment: 3: User

Rendering result

Where:

  • journey: creates a Mermaid user journey diagram
  • title: sets the user journey diagram title
  • section Browse: represents a stage group in the flow
  • Search for products: 5: User: defines the specific tasks, satisfaction scores, and participating actors within a stage

Common syntax

SyntaxdiagramsMeaning
journeyUser journey diagramCreate a user journey diagram
title textTitleUser journey diagram title
section textSection blockDivides stage groups in the flow
TaskName:num:ActorJourney node + satisfaction scale axisDefines the interaction tasks, satisfaction scores, and participating actors within a stage
num (1~5)Satisfaction score1 is the lowest, 5 is the best
Me, CatActorDefines the multiple actors involved in the task

For the detailed syntax for generating user journey diagrams with Mermaid, see the page below: https://www.processon.io/mermaid/user-journey-diagram

User journey diagrams are well suited to analyzing the different steps and experiences a customer goes through from first contact with a product to achieving a goal, and you can try Mermaid online user journey diagram editor.

Mermaid timeline

Basic syntax

Mermaid uses the timeline declaration to create a timeline.

timeline

title Mermaid Development History

2019 : Project Development

2020 : Feature Expansion

2021 : More Diagram Types

Rendering result

Where:

  • timeline: creates a Mermaid timeline
  • title: sets the timeline title
  • 2019 : Project development: defines the event for a point in time

Common syntax

SyntaxdiagramsMeaning
timelineTimelineCreate a timeline
title textTitleSets the timeline title
section textSection blockDivides time period groups
date : Event1EventDefines the event for a point in time
: Event2Multiple eventsAdditional events at the same time
SpaceLine breakWraps overlong event descriptions

For the detailed syntax for generating timelines with Mermaid, see the page below: https://www.processon.io/mermaid/timeline

Timelines are well suited to presenting historical events, project development, product iterations, and chronological information, and you can try Mermaid online timeline editor.

Mermaid quadrant chart syntax

Basic syntax

Mermaid uses the quadrantChart declaration to create a quadrant chart.

quadrantChart

title Product Positioning

x-axis Low Price--> High Price

y-axis Low Quality--> High Quality

quadrant-1 High-end

quadrant-2 Quality-focused

quadrant-3 Basic

quadrant-4 Value-for-money

Product A: [0.8, 0.7]

Product B: [0.3, 0.8]

Rendering result

Where:

  • quadrantChart: creates a Mermaid quadrant chart
  • x-axis: defines the labels at both ends of the x-axis
  • y-axis: defines the labels at both ends of the y-axis
  • quadrant-1: Sets the label text inside the top-right quadrant
  • quadrant-2: Sets the top-left quadrant's label text
  • quadrant-3: Sets the Sets the bottom-left quadrant's label text
  • quadrant-4: Sets the bottom-right quadrant's label text
  • Product A: [0.8, 0.7]: defines the coordinate point, with x/y values from 0 to 1

For the detailed syntax for generating quadrant charts with Mermaid, see the page below: https://www.processon.io/mermaid/quadrant-chart

Quadrant charts are well suited to product positioning, prioritization analysis, competitive analysis, and two-dimensional classification, and you can try Mermaid quadrant chart the online editor.

Mermaid kanban diagram

Basic syntax

Mermaid kanban diagrams organize work items by task status, such as To Do, In Progress, and Done. A typical structure looks like this:

kanban

Todo

Task A

Task B

Doing

Task C

Done

Task D

Rendering result

Where;

  • kanban: creates a Mermaid kanban the diagram
  • Todo: defines a kanban status category
  • Task A: Represents a specific task

For the detailed syntax for generating kanban diagrams with Mermaid, see the page below: https://www.processon.io/mermaid/kanban

Kanban diagrams are well suited to project management, task tracking, development processes, and workflow management, and you can try Mermaid kanban diagram the online editor.

Mermaid requirement diagram

Basic syntax

Requirement diagrams can represent the relationships between requirements, functions, and system elements, Mermaid uses the requirementDiagram declaration to create a requirement diagram.

requirementDiagram

requirement userRequirement {

id: 1

text: Customers can purchase products

risk: low

verifymethod: test

}

Rendering result

Where:

  • requirementDiagram: creates a Mermaid requirement diagram
  • requirement userRequirement { }: defines a basic requirement
  • text: defines the requirement name
  • risk: defines the risk level
  • verifymethod: defines the verification method

Common syntax

SyntaxdiagramsMeaning
requirementDiagramRequirement diagramCreate a requirement diagram
Requirement name { }RequirementDefines a basic requirement
functionalRequirement name { }FunctionDefines a functional requirement
interfaceRequirement name { }InterfaceDefines an interface requirement
performanceRequirement name { }PerformanceDefines a performance requirement
physicalRequirement name { }PhysicalDefines a physical requirement
element name {type: name docRef: name}ElementDefines entity elements such as systems, components, and tests
X - satisfies -> YDashed arrowThe entity satisfies the corresponding requirement
X - contains -> YSolid line with a cross-plus circular endpoint at the startOne requirement contains another requirement
X - derives -> YDashed arrowA requirement is derived from another requirement
X - copies -> YDashed arrowA requirement copies another requirement
X - traces -> YDashed arrowBidirectional traceability between requirements

For the detailed syntax for generating a requirement the diagram diagram with Mermaid, see the page below: https://www.processon.io/mermaid/requirement-diagram

Requirement diagrams are well suited to product requirements analysis, systems engineering, and requirements tracing, and you can try Mermaid requirement diagram the online editor.

Mermaid pie chart

Basic syntax

Mermaid uses the pie declaration to create a pie chart.

pie showData

title Population Share by Continent

"Asia" : 59.5

"Africa" : 18.0

"Europe" : 9.0

"North America" : 7.5

"South America" : 5.5

"Oceania" : 0.5

Rendering result

Where:

  • pie: creates a Mermaid pie chart
  • pie showData: creates a Mermaid pie chart that displays data values
  • title: sets the pie chart title
  • "Asia" : 59.5: defines the data categories and their proportions

For the detailed syntax for generating pie charts with Mermaid, see the page below: https://www.processon.io/mermaid/pie-chart

Pie charts are well suited to showing proportions and composition, and you can try Mermaid pie chart the online editor.

Mermaid Sankey diagram

Basic syntax

Sankey diagrams are mainly used to show the flow of traffic, resources, funds, or data between different nodes, Mermaid uses the sankey-beta declaration to create a Sankey diagram.

sankey-beta

A,B,50

A,C,30

B,D,20

C,D,30

Rendering result

Where:

  • sankey-beta: creates a Mermaid Sankey diagram
  • A,B,50: defines the data flow: source, target, and flow value
  • A: the left node, representing the data input source
  • B: the right node, representing the data output destination
  • 50: represents the flow magnitude

For the detailed syntax for generating Sankey diagrams with Mermaid, see the page below: https://www.processon.io/mermaid/sankey-diagram

A Sankey diagram is a visualization that shows the flow from one set of values to another, and you can try Mermaid Sankey diagram the online editor.

Mermaid XY chart

Basic syntax

Mermaid uses the xychart-beta declaration to create an XY chart.

xychart-beta

title "Monthly Sales Data"

x-axis "Month"["Jan", "Feb", "Mar", "Apr", "May", "Jun"]

y-axis " Sales (million)" 0 --> 100

line [20, 30, 40, 35, 50, 60]

bar [30, 50, 35, 20, 45, 40]

Rendering result

Where:

  • xychart-beta: creates a Mermaid XY chart
  • title: sets the XY chart title
  • x-axis: sets the x-axis categories and title
  • y-axis: sets the y-axis range and title
  • line: defines the line chart data series
  • bar: defines the bar chart data series

Common syntax

SyntaxdiagramsMeaning
xychart-betaXY coordinate chartCreate an XY coordinate chart
xychart-beta horizontalHorizontal XY coordinate chartCreate a horizontal XY coordinate chart
title "name"TitleDefines the XY chart title
x-axis "axisTitle" [a,b,c]X-axisDefines the x-axis categories and title
y-axis "axisTitle" min --> maxY-axisDefines the y-axis range and title
y-axis "axisTitle"Y-axis with title onlySets only the y-axis name; the value range is adjusted automatically
bar [num1, num2, num3]Column chartDefines the bar chart data series
line [num1, num2, num3]Line chartDefines the line chart data series

For the detailed syntax for generating XY charts with Mermaid, see the page below: https://www.processon.io/mermaid/xy-chart

XY charts are well suited to showing data changes, value comparisons, and simple data visualization, and you can try Mermaid XY chart the online editor.

Mermaid radar chart

Basic syntax

Radar charts are well suited to comparing how multiple objects perform across multiple dimensions, such as skill assessments, product metrics, and option comparisons. Mermaid uses radar-beta to create a radar chart.

radar-beta

title "Competency Assessment Radar Chart"

axis a["Communication Skills"], b["Logical Thinking"], c["Team Collaboration"], d["Technical Skills"]

curve A["Chenlaoda"] {80, 90, 70, 85}

curve B["Wangxiaoer"] {60, 70, 90, 80}

Rendering result

Where:

  • radar-beta: creates a Mermaid radar the diagram
  • title: defines the radar chart title
  • axis: defines the radar chart dimensions and their names
  • curve: defines the data series names and the values for each dimension

Common syntax

SyntaxdiagramsMeaning
radar-betaRadar chartCreate a radar chart
title "name"TitleDefines the radar chart title, placed immediately after radar-beta
title "name"TitleDefines the radar chart title, placed before radar-beta, with 3 dashes added both above and below
axis id ["axisTitle"]Dimension axisDefines the radar chart dimensions and their names
curve id ["name"]{[values]}Data curvedefines the data series names and the values for each dimension
max valueMaximumSets the maximum value of the radar chart's value range
min valueMinimumSets the minimum value of the radar chart's value range

For the detailed syntax for generating radar charts with Mermaid, see the page below: https://www.processon.io/mermaid/radar-chart

Radar charts are especially useful for developers, data scientists, and engineers who need to present data clearly and concisely in a circular format, and you can try Mermaid radar chart the online editor.

Mermaid Git graph

Basic syntax

Mermaid uses the gitGraph declaration to create a Git graph.

gitGraph

commit

branch develop

checkout develop

commit

checkout main

merge develop

Rendering result

Where:

  • gitGraph: creates a Mermaid Git graph
  • commit: creates a commit
  • commit id:"": sets the commit name
  • branch: creates a branch
  • checkout: switches branches
  • merge: merges branches

For the detailed syntax for generating Git graphs with Mermaid, see the page below: https://www.processon.io/mermaid/git-graph

Git graphs are well suited to representing version control processes such as Git commits, branch creation, branch switching, and merging, and you can try Mermaid Git graph the online editor.

Mermaid C4 diagram

Basic syntax

Mermaid C4 diagrams are used for software architecture modeling and can describe software systems, containers, components, and their relationships at different levels.

C4Context

title C4 Diagram of the Business System

Person(user, " User", " System user")

System(system, " Business System", " Core business system")

Rel(user, system, "Uses")

Rendering result

Where:

  • C4Context: creates a C4 context diagram
  • title: sets the C4 diagram title
  • Person(user, " User", " System user"): represents a user or role that uses the system
  • System(system, " Business System", " Core business system"): represents a software system that needs to be analyzed
  • Rel(user, system, "Uses"): defines the call, interaction, or data transfer relationship between two elements

Common syntax

SyntaxdiagramsMeaning
C4ContextSystem context diagramCreate a C4 system context diagram
C4ContainerContainer diagramCreate a C4 container diagram
C4ComponentComponent diagramCreate a C4 component diagram
C4DynamicDynamic interaction diagramCreate a C4 dynamic interaction diagram
C4DeploymentDeployment diagramCreate a C4 deployment diagram
titleTitleSets the C4 diagram title
Person(alias, "label", "description")PersonRepresents a user or role that uses the system
Person_Ext(alias, "label", "description")External personRepresents a person or organizational role outside the system that participates in interactions
System(alias, "label", "description")System nodeRepresents a software system that needs to be analyzed
System_Ext(alias, "label", "description")External system nodeRepresents a third-party service or external software system that the system depends on
System_Boundary(alias, "label")System boundaryRepresents the system scope boundary
Container(alias, "label", "technology")ContainerRepresents a software unit inside the system that can run independently
ContainerDb(alias,"label","technology") databaseRepresents a data storage component in the system
Container_Boundary(alias, "label")Container boundaryRepresents the scope of a container or service

For the detailed syntax for generating C4 diagrams with Mermaid, see the page below: https://www.processon.io/mermaid/c4-diagram

C4 diagrams are well suited to software architecture design, system analysis, and technical documentation, and you can try Mermaid C4 diagram the online editor.

Mermaid architecture diagram

Basic syntax

Mermaid uses the architecture-beta declaration to create an architecture diagram.

architecture-beta

group api(cloud)[API server]

service server(server)[server] in api

service database(database)[databasa] in api

server:R --> L:database

Rendering result

Where:

  • architecture-beta: creates a Mermaid architecture diagram.
  • group api(cloud)[API server]: creates an architecture group
  • service server(server)[server] in api: creates an architecture component or service module, and places it in the architecture group
  • server:R --> L:database: specifies the node connection direction, from the right side of server to the left side of database

For the detailed syntax for generating architecture diagrams with Mermaid, see the page below: https://www.processon.io/mermaid/architecture-diagram

Architecture diagrams are well suited to representing the relationships between servers, databases, cloud services, application services, and different system components, and you can try Mermaid architecture diagram the online editor.

Mermaid block diagram

Basic syntax

Block diagrams mainly describe system structure through modules and their connections, Mermaid uses the block-beta declaration to create a block diagram.

block-beta

A space B

A["User"] --> B["Application"]

B space C

B --> C["Database"]

Rendering result

Where:

  • block-beta: creates a Mermaid block diagram
  • space: Increases the spacing between each cell or module
  • -->: solid arrow, indicating the direction of a relationship

For the detailed syntax for generating block diagrams with Mermaid, see the page below: https://www.processon.io/mermaid/block-diagram

Block diagrams are well suited to system modules, functional structures, technical architecture, and component relationships, and you can try Mermaid block diagram the online editor.

Mermaid packet diagram

Basic syntax

Packet diagrams are mainly used to represent the fields and lengths in network packets or protocol data structures, Mermaid uses the packet-beta declaration to create a packet diagram.

packet-beta

0-7: "Version"

8-15: "Type"

16-31: "Length"

Rendering result

Where:

  • packet-beta: creates a Mermaid packet diagram
  • 0-7: "Version ": represents the bit range occupied by a field

Packet diagrams are well suited to network protocols, packet structures, and technical specification documents, and you can try Mermaid packet diagram the online editor.

What if you don't know Mermaid syntax?

Being unfamiliar with Mermaid syntax doesn't mean you can't use Mermaid to generate diagrams, and you can take the following approaches:

Free Mermaid templates

First pick the template closest to what you need, then edit its nodes, text, and relationships. This approach suits users who are using Mermaid for the first time.

Generate Mermaid code with AI

You can simply describe the diagram you need in natural language, for example:

Create an e-commerce order processing flow that includes placing an order, payment, inventory check, shipping, and order completion.

AI can generate Mermaid code from the description, and you can then modify it to fit your actual needs.

Check and fix code with AI

If your Mermaid code has a syntax error, you can have AI help locate the problem and fix the code.

Generate code from an image

For flowcharts, architecture diagrams, or other structured diagrams that already exist, you can try generating Mermaid code through image recognition and then continue editing.

What features does the Mermaid online editor offer?

A Mermaid online editor usually has to solve three core problems: writing code, previewing diagrams, and exporting results. On top of that, templates and AI can also lower the barrier to using Mermaid.

Take ProcessOn Mermaid the online editor as an example - in the browser you can directly:

  • Write Mermaid code
  • Paste existing Mermaid code
  • Real-time rendering and preview the diagram
  • Free Mermaid templates
  • Natural language AI-generated Mermaid diagrams
  • AI checking and fixing Mermaid code
  • Use image recognition to generate Mermaid code
  • Further edit the generated diagram and modify it
  • Export PNG, PDF, SVG, JPG, and Markdown

So for those who need to create Mermaid diagrams diagrams frequently, ProcessOn Mermaid an online editor can bring Mermaid code writing, diagrams generation, re-editing and, export, and sharing together in one working environment.

From Mermaid flowcharts, sequence diagrams, and class diagrams to Gantt charts, mind maps, quadrant charts, Sankey diagrams, Git graphs, C4 diagrams, and architecture diagrams, all of them can be created with Mermaid syntax and edited.

Come and use the Mermaid online editor, write Mermaid code online and generate diagrams!

FAQ

Is Mermaid syntax hard to learn?

Mermaid's basic syntax is relatively simple, and for most diagrams you only need to master the basic forms of a diagram declaration, nodes, lines, and text. For example, sequenceDiagram declares a sequence diagram and flowchart declares a flowchart. Syntax rules differ between diagram types, and complex diagrams require further study of the corresponding parameters and configuration.

Why can't Mermaid generate a diagram when the code is wrong?

Mermaid is fairly sensitive to syntax structure. Common causes include an incorrect diagram declaration, incomplete node or line syntax, incorrect handling of indentation or special characters, and use of syntax that the current Mermaid version does not support.

What is the difference between Mermaid and traditional drawing software?

Mermaid mainly describes diagrams through text code, whereas traditional drawing software usually creates diagrams by dragging shapes and lines and adjusting styles.

Can Mermaid diagrams be saved and reused?

Yes. The core content of a Mermaid diagram is text code, so you can save the code in Markdown, a code file, or another document that supports Mermaid, and render it again whenever needed.

This is also an important difference between Mermaid and diagrams that exist purely as images: An image stores the final result, whereas Mermaid code also stores the diagram's structural information.

How does Mermaid relate to Markdown?

Mermaid is often used together with Markdown, but the two are not the same syntax.

Markdown is mainly used to write structured text, while Mermaid is used to generate diagrams through code. In a Markdown editor that supports Mermaid, you can embed Mermaid code in a Markdown document, so that the diagram and the accompanying text are in the same document.

Could you please log in to support the author?
Document