Three tiers
columns 3 places the next three blocks on one row. The arrows repeat the reading order.
block-beta
columns 3
web["Web app"] api["API"] db[("Database")]
web --> api
api --> dbBlock diagrams place labeled boxes on a grid and connect them. You control the columns, then fill the cells left to right.
Copy an example, or open it in the live editor with this diagram already loaded.
columns 3 places the next three blocks on one row. The arrows repeat the reading order.
block-beta
columns 3
web["Web app"] api["API"] db[("Database")]
web --> api
api --> dbThe :2 suffix spans two columns. space would leave a single cell empty if you needed a gap instead.
block-beta
columns 2
edge["Edge cache"]:2
app["Application"] db[("Postgres")]
edge --> app
app --> dbBrackets pick the shape. A cylinder marks storage, and a diamond marks a decision you still want in the grid.
block-beta
columns 1
req["Request"]
choice{"Cache hit?"}
store[("Cache")]
req --> choice
choice --> storeA Mermaid block diagram is a grid of blocks. block-beta starts the diagram, columns N sets the width, and the following lines fill cells from left to right. A block is an id plus a label, such as api["API"]. Shapes follow the same brackets as flowcharts: [ ] rectangle, ( ) rounded, [( )] cylinder, { } diamond. space leaves a cell empty, and id:2 makes a block span two columns. Arrows use the flowchart form A --> B. Use a block diagram for a structured layout. Use a flowchart when the story is a process rather than a grid.
Use a block diagram for a fixed layout: a request path across three tiers, or a page of labeled parts. Use a flowchart for decisions. Use a C4 diagram when the boxes need the C4 types and descriptions.
Edit this block diagram in the live editor, read the Mermaid cheat sheet, or compare it with Flowchart, C4 Diagram and Architecture Diagram.
| Element | Syntax | Description |
|---|---|---|
| Columns | columns N | Set grid column count |
| Block | id["Label"] | Define a named block |
| Space | space | Empty grid cell |
| Span columns | id:N | Block spans N columns |
| Connection | A --> B | Connect blocks with arrow |
| Block arrow | id<["text"]>(direction) | Arrow-shaped block |
Setting columns 3 and then wondering why the fourth block wraps.
The column count is the wrap width. Change columns, or span a block with :2, until the grid matches the picture you want.
Drawing an arrow to a label instead of an id.
Arrows use the id, the token before the brackets. web["Web app"] is linked as web, not as Web app.
Using a block diagram for a long decision process.
The grid fights a branching process. Move that diagram to a flowchart.
Block diagrams are architecture sketches. SVG is the better docs export. Free PNG exports include a watermark.
High-resolution images for documents and presentations.
Scalable vectors for web and further editing.
Print-ready format for professional documentation.
Got Mermaid code from ChatGPT? Paste it here to render and export instantly.
All 21 diagram types in one PDF reference.
Open the editor with this example pre-loaded and start customizing.
Design process flows, decision trees, and workflows with our intuitive flowchart editor.
Visualize software architecture at multiple levels with the C4 model — context, containers, and components.
Visualize cloud infrastructure, service architectures, and system design with architecture diagrams.