Skip to content

Flowcharts - Basic Syntax ​

Flowcharts are composed of nodes (geometric shapes) and edges (arrows or lines). The Mermaid code defines how nodes and edges are made and accommodates different arrow types, multi-directional arrows, and any linking to and from subgraphs.

WARNING

If you are using the word "end" in a Flowchart node, capitalize the entire word or any of the letters (e.g., "End" or "END"), or apply this workaround. Typing "end" in all lowercase letters will break the Flowchart.

WARNING

If you are using the letter "o" or "x" as the first letter in a connecting Flowchart node, add a space before the letter or capitalize the letter (e.g., "dev--- ops", "dev---Ops").

Typing "A---oB" will create a circle edge.

Typing "A---xB" will create a cross edge.

A node (default) ​

Code:
mermaid
Ctrl + Enter|

INFO

The id is what is displayed in the box.

TIP

Instead of flowchart one can also use graph.

A node with text ​

It is also possible to set text in the box that differs from the id. If this is done several times, it is the last text found for the node that will be used. Also if you define edges for the node later on, you can omit text definitions. The one previously defined will be used when rendering the box.

Code:
mermaid
Ctrl + Enter|

Unicode text ​

Use " to enclose the unicode text.

Code:
mermaid
Ctrl + Enter|

Markdown formatting ​

Use double quotes and backticks "` text `" to enclose the markdown text.

Code:
mermaid
Ctrl + Enter|

Direction ​

This statement declares the direction of the Flowchart.

This declares the flowchart is oriented from top to bottom (TD or TB).

Code:
mermaid
Ctrl + Enter|

This declares the flowchart is oriented from left to right (LR).

Code:
mermaid
Ctrl + Enter|

Possible FlowChart orientations are:

  • TB - Top to bottom
  • TD - Top-down/ same as top to bottom
  • BT - Bottom to top
  • RL - Right to left
  • LR - Left to right

Node shapes ​

A node with round edges ​

Code:
mermaid
Ctrl + Enter|

A stadium-shaped node ​

Code:
mermaid
Ctrl + Enter|

A node in a subroutine shape ​

Code:
mermaid
Ctrl + Enter|

A node in a cylindrical shape ​

Code:
mermaid
Ctrl + Enter|

A node in the form of a circle ​

Code:
mermaid
Ctrl + Enter|

A node in an asymmetric shape ​

Code:
mermaid
Ctrl + Enter|

Currently only the shape above is possible and not its mirror. This might change with future releases.

A node (rhombus) ​

Code:
mermaid
Ctrl + Enter|

A hexagon node ​

Code:
mermaid
Ctrl + Enter|

Parallelogram ​

Code:
mermaid
Ctrl + Enter|

Parallelogram alt ​

Code:
mermaid
Ctrl + Enter|

Trapezoid ​

Code:
mermaid
Ctrl + Enter|

Trapezoid alt ​

Code:
mermaid
Ctrl + Enter|

Double circle ​

Code:
mermaid
Ctrl + Enter|

Expanded Node Shapes in Mermaid Flowcharts (v11.3.0+) ​

Mermaid introduces 30 new shapes to enhance the flexibility and precision of flowchart creation. These new shapes provide more options to represent processes, decisions, events, data storage visually, and other elements within your flowcharts, improving clarity and semantic meaning.

New Syntax for Shape Definition

Mermaid now supports a general syntax for defining shape types to accommodate the growing number of shapes. This syntax allows you to assign specific shapes to nodes using a clear and flexible format:

A@{ shape: rect }

This syntax creates a node A as a rectangle. It renders in the same way as A["A"], or A.

Complete List of New Shapes ​

Below is a comprehensive list of the newly introduced shapes and their corresponding semantic meanings, short names, and aliases:

Semantic NameShape NameShort NameDescriptionAlias Supported
CardNotched Rectanglenotch-rectRepresents a cardcard, notched-rectangle
CollateHourglasshourglassRepresents a collate operationcollate, hourglass
Com LinkLightning BoltboltCommunication linkcom-link, lightning-bolt
CommentCurly BracebraceAdds a commentbrace-l, comment
Comment RightCurly Bracebrace-rAdds a comment
Comment with braces on both sidesCurly BracesbracesAdds a comment
Data Input/OutputLean Rightlean-rRepresents input or outputin-out, lean-right
Data Input/OutputLean Leftlean-lRepresents output or inputlean-left, out-in
DatabaseCylindercylDatabase storagecylinder, database, db
DecisionDiamonddiamDecision-making stepdecision, diamond, question
DelayHalf-Rounded RectangledelayRepresents a delayhalf-rounded-rectangle
Direct Access StorageHorizontal Cylinderh-cylDirect access storagedas, horizontal-cylinder
Disk StorageLined Cylinderlin-cylDisk storagedisk, lined-cylinder
DisplayCurved Trapezoidcurv-trapRepresents a displaycurved-trapezoid, display
Divided ProcessDivided Rectanglediv-rectDivided process shapediv-proc, divided-process, divided-rectangle
DocumentDocumentdocRepresents a documentdoc, document
EventRounded RectangleroundedRepresents an eventevent
ExtractTriangletriExtraction processextract, triangle
Fork/JoinFilled RectangleforkFork or join in process flowjoin
Internal StorageWindow Panewin-paneInternal storageinternal-storage, window-pane
JunctionFilled Circlef-circJunction pointfilled-circle, junction
Lined DocumentLined Documentlin-docLined documentlined-document
Lined/Shaded ProcessLined Rectanglelin-rectLined process shapelin-proc, lined-process, lined-rectangle, shaded-process
Loop LimitTrapezoidal Pentagonnotch-pentLoop limit steploop-limit, notched-pentagon
Manual FileFlipped Triangleflip-triManual file operationflipped-triangle, manual-file
Manual InputSloped Rectanglesl-rectManual input stepmanual-input, sloped-rectangle
Manual OperationTrapezoid Base Toptrap-tRepresents a manual taskinv-trapezoid, manual, trapezoid-top
Multi-DocumentStacked DocumentdocsMultiple documentsdocuments, st-doc, stacked-document
Multi-ProcessStacked Rectanglest-rectMultiple processesprocesses, procs, stacked-rectangle
OddOddoddOdd shape
Paper TapeFlagflagPaper tapepaper-tape
Prepare ConditionalHexagonhexPreparation or condition stephexagon, prepare
Priority ActionTrapezoid Base Bottomtrap-bPriority actionpriority, trapezoid, trapezoid-bottom
ProcessRectanglerectStandard process shapeproc, process, rectangle
StartCirclecircleStarting pointcirc
StartSmall Circlesm-circSmall starting pointsmall-circle, start
StopDouble Circledbl-circRepresents a stop pointdouble-circle
StopFramed Circlefr-circStop pointframed-circle, stop
Stored DataBow Tie Rectanglebow-rectStored databow-tie-rectangle, stored-data
SubprocessFramed Rectanglefr-rectSubprocessframed-rectangle, subproc, subprocess, subroutine
SummaryCrossed Circlecross-circSummarycrossed-circle, summary
Tagged DocumentTagged Documenttag-docTagged documenttag-doc, tagged-document
Tagged ProcessTagged Rectangletag-rectTagged processtag-proc, tagged-process, tagged-rectangle
Terminal PointStadiumstadiumTerminal pointpill, terminal
Text BlockText BlocktextText block

Example Flowchart with New Shapes ​

Here’s an example flowchart that utilizes some of the newly introduced shapes:

Code:
mermaid
Ctrl + Enter|

Process ​

Code:
mermaid
Ctrl + Enter|

Event ​

Code:
mermaid
Ctrl + Enter|

Terminal Point (Stadium) ​

Code:
mermaid
Ctrl + Enter|

Subprocess ​

Code:
mermaid
Ctrl + Enter|

Database (Cylinder) ​

Code:
mermaid
Ctrl + Enter|

Start (Circle) ​

Code:
mermaid
Ctrl + Enter|

Odd ​

Code:
mermaid
Ctrl + Enter|

Decision (Diamond) ​

Code:
mermaid
Ctrl + Enter|

Prepare Conditional (Hexagon) ​

Code:
mermaid
Ctrl + Enter|

Data Input/Output (Lean Right) ​

Code:
mermaid
Ctrl + Enter|

Data Input/Output (Lean Left) ​

Code:
mermaid
Ctrl + Enter|

Priority Action (Trapezoid Base Bottom) ​

Code:
mermaid
Ctrl + Enter|

Manual Operation (Trapezoid Base Top) ​

Code:
mermaid
Ctrl + Enter|

Stop (Double Circle) ​

Code:
mermaid
Ctrl + Enter|

Text Block ​

Code:
mermaid
Ctrl + Enter|

Card (Notched Rectangle) ​

Code:
mermaid
Ctrl + Enter|

Lined/Shaded Process ​

Code:
mermaid
Ctrl + Enter|

Start (Small Circle) ​

Code:
mermaid
Ctrl + Enter|

Stop (Framed Circle) ​

Code:
mermaid
Ctrl + Enter|

Fork/Join (Long Rectangle) ​

Code:
mermaid
Ctrl + Enter|

Collate (Hourglass) ​

Code:
mermaid
Ctrl + Enter|

Comment (Curly Brace) ​

Code:
mermaid
Ctrl + Enter|

Comment Right (Curly Brace Right) ​

Code:
mermaid
Ctrl + Enter|

Comment with braces on both sides ​

Code:
mermaid
Ctrl + Enter|
Code:
mermaid
Ctrl + Enter|

Document ​

Code:
mermaid
Ctrl + Enter|

Delay (Half-Rounded Rectangle) ​

Code:
mermaid
Ctrl + Enter|

Direct Access Storage (Horizontal Cylinder) ​

Code:
mermaid
Ctrl + Enter|

Disk Storage (Lined Cylinder) ​

Code:
mermaid
Ctrl + Enter|

Display (Curved Trapezoid) ​

Code:
mermaid
Ctrl + Enter|

Divided Process (Divided Rectangle) ​

Code:
mermaid
Ctrl + Enter|

Extract (Small Triangle) ​

Code:
mermaid
Ctrl + Enter|

Internal Storage (Window Pane) ​

Code:
mermaid
Ctrl + Enter|

Junction (Filled Circle) ​

Code:
mermaid
Ctrl + Enter|

Lined Document ​

Code:
mermaid
Ctrl + Enter|

Loop Limit (Notched Pentagon) ​

Code:
mermaid
Ctrl + Enter|

Manual File (Flipped Triangle) ​

Code:
mermaid
Ctrl + Enter|

Manual Input (Sloped Rectangle) ​

Code:
mermaid
Ctrl + Enter|

Multi-Document (Stacked Document) ​

Code:
mermaid
Ctrl + Enter|

Multi-Process (Stacked Rectangle) ​

Code:
mermaid
Ctrl + Enter|

Paper Tape (Flag) ​

Code:
mermaid
Ctrl + Enter|

Stored Data (Bow Tie Rectangle) ​

Code:
mermaid
Ctrl + Enter|

Summary (Crossed Circle) ​

Code:
mermaid
Ctrl + Enter|

Tagged Document ​

Code:
mermaid
Ctrl + Enter|

Tagged Process (Tagged Rectangle) ​

Code:
mermaid
Ctrl + Enter|

Special shapes in Mermaid Flowcharts (v11.3.0+) ​

Mermaid also introduces 2 special shapes to enhance your flowcharts: icon and image. These shapes allow you to include icons and images directly within your flowcharts, providing more visual context and clarity.

Icon Shape ​

You can use the icon shape to include an icon in your flowchart. To use icons, you need to register the icon pack first. Follow the instructions provided here. The syntax for defining an icon shape is as follows:

Code:
mermaid
Ctrl + Enter|

Parameters ​

  • icon: The name of the icon from the registered icon pack.
  • form: Specifies the background shape of the icon. If not defined there will be no background to icon. Options include:
    • square
    • circle
    • rounded
  • label: The text label associated with the icon. This can be any string. If not defined, no label will be displayed.
  • pos: The position of the label. If not defined label will default to bottom of icon. Possible values are:
    • t
    • b
  • h: The height of the icon. If not defined this will default to 48 which is minimum.

Image Shape ​

You can use the image shape to include an image in your flowchart. The syntax for defining an image shape is as follows:

Code:
mermaid
Ctrl + Enter|

Parameters ​

  • img: The URL of the image to be displayed.
  • label: The text label associated with the image. This can be any string. If not defined, no label will be displayed.
  • pos: The position of the label. If not defined, the label will default to the bottom of the image. Possible values are:
    • t
    • b
  • w: The width of the image. If not defined, this will default to the natural width of the image.
  • h: The height of the image. If not defined, this will default to the natural height of the image.
  • constraint: Determines if the image should constrain the node size. This setting also ensures the image maintains its original aspect ratio, adjusting the height (h) accordingly to the width (w). If not defined, this will default to off Possible values are:
    • on
    • off

These new shapes provide additional flexibility and visual appeal to your flowcharts, making them more informative and engaging.

Nodes can be connected with links/edges. It is possible to have different types of links or attach a text string to a link.

Code:
mermaid
Ctrl + Enter|
Code:
mermaid
Ctrl + Enter|
Code:
mermaid
Ctrl + Enter|

or

Code:
mermaid
Ctrl + Enter|
Code:
mermaid
Ctrl + Enter|

or

Code:
mermaid
Ctrl + Enter|
Code:
mermaid
Ctrl + Enter|
Code:
mermaid
Ctrl + Enter|
Code:
mermaid
Ctrl + Enter|
Code:
mermaid
Ctrl + Enter|

This can be a useful tool in some instances where you want to alter the default positioning of a node.

Code:
mermaid
Ctrl + Enter|

It is possible declare many links in the same line as per below:

Code:
mermaid
Ctrl + Enter|

It is also possible to declare multiple nodes links in the same line as per below:

Code:
mermaid
Ctrl + Enter|

You can then describe dependencies in a very expressive way. Like the one-liner below:

Code:
mermaid
Ctrl + Enter|

If you describe the same diagram using the basic syntax, it will take four lines. A word of warning, one could go overboard with this making the flowchart harder to read in markdown form. The Swedish word lagom comes to mind. It means, not too much and not too little. This goes for expressive syntaxes as well.

Code:
mermaid
Ctrl + Enter|

Attaching an ID to Edges ​

Mermaid now supports assigning IDs to edges, similar to how IDs and metadata can be attached to nodes. This feature lays the groundwork for more advanced styling, classes, and animation capabilities on edges.

Syntax:

To give an edge an ID, prepend the edge syntax with the ID followed by an @ character. For example:

Code:
mermaid
Ctrl + Enter|

In this example, e1 is the ID of the edge connecting A to B. You can then use this ID in later definitions or style statements, just like with nodes.

Turning an Animation On ​

Once you have assigned an ID to an edge, you can turn on animations for that edge by defining the edge’s properties:

Code:
mermaid
Ctrl + Enter|

This tells Mermaid that the edge e1 should be animated.

Selecting Type of Animation ​

In the initial version, two animation speeds are supported: fast and slow. Selecting a specific animation type is a shorthand for enabling animation and setting the animation speed in one go.

Examples:

Code:
mermaid
Ctrl + Enter|

This is equivalent to { animate: true, animation: fast }.

Using classDef Statements for Animations ​

You can also animate edges by assigning a class to them and then defining animation properties in a classDef statement. For example:

Code:
mermaid
Ctrl + Enter|

In this snippet:

  • e1@--> creates an edge with ID e1.
  • classDef animate defines a class named animate with styling and animation properties.
  • class e1 animate applies the animate class to the edge e1.

Note on Escaping Commas: When setting the stroke-dasharray property, remember to escape commas as \, since commas are used as delimiters in Mermaid’s style definitions.

New arrow types ​

There are new types of arrows supported:

  • circle edge
  • cross edge

Circle edge example ​

Code:
mermaid
Ctrl + Enter|

Cross edge example ​

Code:
mermaid
Ctrl + Enter|

Multi directional arrows ​

There is the possibility to use multidirectional arrows.

Code:
mermaid
Ctrl + Enter|

Each node in the flowchart is ultimately assigned to a rank in the rendered graph, i.e. to a vertical or horizontal level (depending on the flowchart orientation), based on the nodes to which it is linked. By default, links can span any number of ranks, but you can ask for any link to be longer than the others by adding extra dashes in the link definition.

In the following example, two extra dashes are added in the link from node B to node E, so that it spans two more ranks than regular links:

Code:
mermaid
Ctrl + Enter|

Note Links may still be made longer than the requested number of ranks by the rendering engine to accommodate other requests.

When the link label is written in the middle of the link, the extra dashes must be added on the right side of the link. The following example is equivalent to the previous one:

Code:
mermaid
Ctrl + Enter|

For dotted or thick links, the characters to add are equals signs or dots, as summed up in the following table:

Length123
Normal------------
Normal with arrow-->--->---->
Thick============
Thick with arrow==>===>====>
Dotted-.--..--...-
Dotted with arrow-.->-..->-...->

Special characters that break syntax ​

It is possible to put text within quotes in order to render more troublesome characters. As in the example below:

Code:
mermaid
Ctrl + Enter|

Entity codes to escape characters ​

It is possible to escape characters using the syntax exemplified here.

Code:
mermaid
Ctrl + Enter|

Numbers given are base 10, so # can be encoded as #35;. It is also supported to use HTML character names.

Subgraphs ​

subgraph title
    graph definition
end

An example below:

Code:
mermaid
Ctrl + Enter|

You can also set an explicit id for the subgraph.

Code:
mermaid
Ctrl + Enter|

flowcharts ​

With the graphtype flowchart it is also possible to set edges to and from subgraphs as in the flowchart below.

Code:
mermaid
Ctrl + Enter|

Direction in subgraphs ​

With the graphtype flowcharts you can use the direction statement to set the direction which the subgraph will render like in this example.

Code:
mermaid
Ctrl + Enter|

Limitation ​

If any of a subgraph's nodes are linked to the outside, subgraph direction will be ignored. Instead the subgraph will inherit the direction of the parent graph:

Code:
mermaid
Ctrl + Enter|

Markdown Strings ​

The "Markdown Strings" feature enhances flowcharts and mind maps by offering a more versatile string type, which supports text formatting options such as bold and italics, and automatically wraps text within labels.

Code:
mermaid
Ctrl + Enter|

Formatting:

  • For bold text, use double asterisks (**) before and after the text.
  • For italics, use single asterisks (*) before and after the text.
  • With traditional strings, you needed to add <br> tags for text to wrap in nodes. However, markdown strings automatically wrap text when it becomes too long and allows you to start a new line by simply using a newline character instead of a <br> tag.

This feature is applicable to node labels, edge labels, and subgraph labels.

The auto wrapping can be disabled by using

---
config:
  markdownAutoWrap: false
---
graph LR

Interaction ​

It is possible to bind a click event to a node, the click can lead to either a javascript callback or to a link which will be opened in a new browser tab.

INFO

This functionality is disabled when using securityLevel='strict' and enabled when using securityLevel='loose'.

click nodeId callback
click nodeId call callback()
  • nodeId is the id of the node
  • callback is the name of a javascript function defined on the page displaying the graph, the function will be called with the nodeId as parameter.

Examples of tooltip usage below:

html
<script>
  window.callback = function () {
    alert('A callback was triggered');
  };
</script>

The tooltip text is surrounded in double quotes. The styles of the tooltip are set by the class .mermaidTooltip.

Code:
mermaid
Ctrl + Enter|

Success The tooltip functionality and the ability to link to urls are available from version 0.5.2.

?> Due to limitations with how Docsify handles JavaScript callback functions, an alternate working demo for the above code can be viewed at this jsfiddle.

Links are opened in the same browser tab/window by default. It is possible to change this by adding a link target to the click definition (_self, _blank, _parent and _top are supported):

Code:
mermaid
Ctrl + Enter|

Beginner's tipβ€”a full example using interactive links in a html context:

html
<body>
  <pre class="mermaid">
    flowchart LR
        A-->B
        B-->C
        C-->D
        click A callback "Tooltip"
        click B "https://www.github.com" "This is a link"
        click C call callback() "Tooltip"
        click D href "https://www.github.com" "This is a link"
  </pre>

  <script>
    window.callback = function () {
      alert('A callback was triggered');
    };
    const config = {
      startOnLoad: true,
      flowchart: { useMaxWidth: true, htmlLabels: true, curve: 'cardinal' },
      securityLevel: 'loose',
    };
    mermaid.initialize(config);
  </script>
</body>

Comments ​

Comments can be entered within a flow diagram, which will be ignored by the parser. Comments need to be on their own line, and must be prefaced with %% (double percent signs). Any text after the start of the comment to the next newline will be treated as a comment, including any flow syntax

Code:
mermaid
Ctrl + Enter|

Styling and classes ​

It is possible to style links. For instance, you might want to style a link that is going backwards in the flow. As links have no ids in the same way as nodes, some other way of deciding what style the links should be attached to is required. Instead of ids, the order number of when the link was defined in the graph is used, or use default to apply to all links. In the example below the style defined in the linkStyle statement will belong to the fourth link in the graph:

linkStyle 3 stroke:#ff3,stroke-width:4px,color:red;

It is also possible to add style to multiple links in a single statement, by separating link numbers with commas:

linkStyle 1,2,7 color:blue;

Styling line curves ​

It is possible to style the type of curve used for lines between items, if the default method does not meet your needs. Available curve styles include basis, bumpX, bumpY, cardinal, catmullRom, linear, monotoneX, monotoneY, natural, step, stepAfter, and stepBefore.

In this example, a left-to-right graph uses the stepBefore curve style:

%%{ init: { 'flowchart': { 'curve': 'stepBefore' } } }%%
graph LR

For a full list of available curves, including an explanation of custom curves, refer to the Shapes documentation in the d3-shape project.

Styling a node ​

It is possible to apply specific styles such as a thicker border or a different background color to a node.

Code:
mermaid
Ctrl + Enter|

Classes ​

More convenient than defining the style every time is to define a class of styles and attach this class to the nodes that should have a different look.

A class definition looks like the example below:

    classDef className fill:#f9f,stroke:#333,stroke-width:4px;

Also, it is possible to define style to multiple classes in one statement:

    classDef firstClassName,secondClassName font-size:12pt;

Attachment of a class to a node is done as per below:

    class nodeId1 className;

It is also possible to attach a class to a list of nodes in one statement:

    class nodeId1,nodeId2 className;

A shorter form of adding a class is to attach the classname to the node using the :::operator as per below:

Code:
mermaid
Ctrl + Enter|

This form can be used when declaring multiple links between nodes:

Code:
mermaid
Ctrl + Enter|

CSS classes ​

It is also possible to predefine classes in CSS styles that can be applied from the graph definition as in the example below:

Example style

html
<style>
  .cssClass > rect {
    fill: #ff0000;
    stroke: #ffff00;
    stroke-width: 4px;
  }
</style>

Example definition

Code:
mermaid
Ctrl + Enter|

Default class ​

If a class is named default it will be assigned to all classes without specific class definitions.

    classDef default fill:#f9f,stroke:#333,stroke-width:4px;

Basic support for fontawesome ​

It is possible to add icons from fontawesome.

The icons are accessed via the syntax fa:#icon class name#.

Code:
mermaid
Ctrl + Enter|

Mermaid supports Font Awesome if the CSS is included on the website. Mermaid does not have any restriction on the version of Font Awesome that can be used.

Please refer the Official Font Awesome Documentation on how to include it in your website.

Adding this snippet in the <head> would add support for Font Awesome v6.5.1

html
<link
  href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/css/all.min.css"
  rel="stylesheet"
/>

Custom icons ​

It is possible to use custom icons served from Font Awesome as long as the website imports the corresponding kit.

Note that this is currently a paid feature from Font Awesome.

For custom icons, you need to use the fak prefix.

Example

flowchart TD
    B[fa:fa-twitter] %% standard icon
    B-->E(fak:fa-custom-icon-name) %% custom icon

And trying to render it

Code:
mermaid
Ctrl + Enter|
  • In graph declarations, the statements also can now end without a semicolon. After release 0.2.16, ending a graph statement with semicolon is just optional. So the below graph declaration is also valid along with the old declarations of the graph.

  • A single space is allowed between vertices and the link. However there should not be any space between a vertex and its text and a link and its text. The old syntax of graph declaration will also work and hence this new feature is optional and is introduced to improve readability.

Below is the new declaration of the graph edges which is also valid along with the old declaration of the graph edges.

Code:
mermaid
Ctrl + Enter|

Configuration ​

Renderer ​

The layout of the diagram is done with the renderer. The default renderer is dagre.

Starting with Mermaid version 9.4, you can use an alternate renderer named elk. The elk renderer is better for larger and/or more complex diagrams.

The elk renderer is an experimental feature. You can change the renderer to elk by adding this directive:

%%{init: {"flowchart": {"defaultRenderer": "elk"}} }%%

INFO

Note that the site needs to use mermaid version 9.4+ for this to work and have this featured enabled in the lazy-loading configuration.

Width ​

It is possible to adjust the width of the rendered flowchart.

This is done by defining mermaid.flowchartConfig or by the CLI to use a JSON file with the configuration. How to use the CLI is described in the mermaidCLI page. mermaid.flowchartConfig can be set to a JSON string with config parameters or the corresponding object.

javascript
mermaid.flowchartConfig = {
    width: 100%
}