Skip to content
MermaidViewer

Software diagram

Mermaid Block Diagram

Lay out system components in a grid you control, with spans and nesting.

Basic block diagram example

Basic block diagram example diagram
mermaid
block
    columns 3
    Client["Browser"]:3
    space:3
    Web["Web server"] API["API"] Worker["Worker"]
    space:3
    DB[("PostgreSQL")]:2 Cache["Redis"]
    Client --> API
    API --> DB
    Worker --> DB
    API --> Cache
Open in the live editor

Block diagrams give you control over layout. Instead of letting Mermaid position everything automatically, you define a grid with a number of columns and place blocks in it — useful when the spatial arrangement carries meaning.

They work well for system overviews, hardware diagrams, network layers and any picture where you want boxes aligned in rows and columns.

When to use a block diagram

  • High-level system overviews
  • Layered architectures
  • Hardware and network diagrams
  • Dashboards and page layouts

Block Diagram syntax reference

SyntaxWhat it does
block (or block-beta)Start a block diagram.
columns 3Number of columns in the grid.
a["Label"]A block with a label; shapes like flowchart nodes.
a:2Block spanning two columns.
space / space:2Empty cell(s) for spacing.
block:group ... endNested block containing other blocks.
a --> bArrow between blocks.

Block Diagram examples

Layered architecture

Full-width layers stacked vertically.

Layered architecture diagram
mermaid
block
    columns 1
    UI["Presentation layer"]
    App["Application layer"]
    Domain["Domain layer"]
    Infra["Infrastructure layer"]
Open in the live editor

Tips and best practices

  • Sketch the grid first — decide how many columns you need and which blocks should span.
  • Use space blocks to create breathing room between rows.
  • Prefer flowcharts when you want automatic layout and blocks when position matters.

Generate a block diagram with AI

Not sure where to start? Describe what you need and the AI block diagram generator writes the Mermaid code for you. Try prompts like:

  • “Smart home system components”
  • “Three-tier web application”
  • “CPU and memory hierarchy”

Block Diagram templates

Block Diagram FAQ

How is a block diagram different from a flowchart?

A flowchart is laid out automatically, while a block diagram lets you choose the number of columns, spans and empty spaces so blocks appear exactly where you want them.

Is it block or block-beta?

Newer Mermaid versions accept block; older versions need block-beta. MermaidViewer supports both.