Original Mermaid layouts fall apart past ten nodes
Mermaid is great as a source-of-truth language: commit it to the repo, render it in docs, keep it next to the code it describes. But the original layout engine is tuned for correctness, not for readability. Past a certain complexity — roughly ten nodes, a couple of branches, one loop — the output stops reading like a flow and starts reading like a puzzle. You can feel it: the main path zig-zags, decisions lose emphasis, retries cross the diagram diagonally, and the eye has to hunt for the start.
The fix is not to abandon Mermaid. The fix is to keep Mermaid as the source and beautify the output. This guide walks through what a readable flowchart needs, three real before/after examples you can open in the editor, and five techniques that will improve every flowchart you ship — whether you use a tool or tune layouts by hand.
Why original Mermaid flowcharts feel cramped
Three issues compound on any flow that isn’t a straight line:
- The spine wanders. Mermaid doesn’t know which path is the main story, so it lays everything on a grid. When every node gets equal emphasis, nothing gets emphasis.
- Decisions don’t announce themselves. A diamond is a shape, not a visual hierarchy. On a real flow, you want the reader to see that here, the flow splits — the original render buries that signal in node spacing.
- Retries and merges cross the diagram. Any cycle or convergence forces the engine to route an edge backward, and those edges almost always cross another edge. Cross-overs are the single biggest predictor of a flowchart reader going “wait, which arrow goes where?”
These aren’t Mermaid bugs — they’re constraints of a general-purpose layout algorithm. Beauty Diagram’s approach is to classify the flow (linear, branch, retry, composite) and apply a layout intent that targets those specific issues.
What a readable flowchart needs
Four principles show up across every diagram we beautify. Internalise these and you’ll also produce better hand-drawn flowcharts.
- Centered main path. The reader’s eye should land on the entry node and travel down (or right) without detour. Branches peel off the spine; they don’t become the spine.
- Consistent branch rhythm. When a decision splits, both outputs should feel like peers — same vertical level, mirrored spacing. Asymmetry reads as “one of these is more important,” which is usually not what you mean.
- Emphasised decisions. A decision node isn’t just a diamond. It’s a visual break: the flow pauses, asks a question, then resumes. The layout should honor that pause with whitespace, not just render a different shape.
- Explicit loops and merges. A retry path should obviously go back; a merge should obviously converge. If the reader can’t tell at a glance whether an arrow goes forward or backward, the layout failed.
Three before/after case studies
Case A — A linear pipeline
Webhook ingestion. Five nodes in a straight line. Even on the simplest flow, the beautifier tightens spacing and lifts typographic contrast on the entry and exit nodes.
1flowchart TD2 A[Receive webhook] --> B[Validate signature]3 B --> C[Parse payload]4 C --> D[Persist event]5 D --> E[Enqueue downstream job]What changed and why. The original render scatters nodes vertically with uneven gaps; beautified version centers the spine and gives every step identical visual weight. For a linear flow the point is momentum — the reader should feel “step, step, step” without breaks.
Case B — Branch with retry
Job submission with validation and retry. Two decisions, a retry loop that re-enters the validator, and two terminal paths. This is where the original Mermaid render starts to crack.
1flowchart LR2 A[Submit job] --> B{Validate?}3 B -->|valid| C[Run job]4 B -->|invalid| D[Return 400]5 C --> E{Succeeded?}6 E -->|yes| F[Return result]7 E -->|no| G[Log and retry]8 G --> BWhat changed and why. The retry edge (G --> B) is the story of this diagram — it’s what tells the reader “this system is resilient.” The beautified version routes it as an explicit loop-return, not a random diagonal. Decision diamonds get breathing room so the reader can see the flow pauses there.
Case C — Composite orchestration with subgraphs
Three conceptual modules — Ingest, Enrich, Persist — each with internal steps and cross-module handoffs. This is where subgraphs earn their keep.
1flowchart TD2 subgraph Ingest3 I1[Receive event] --> I2[Normalize]4 end5 subgraph Enrich6 E1[Lookup user] --> E2[Attach metadata]7 end8 subgraph Persist9 P1[Write primary] --> P2[Replicate]10 end11 I2 --> E112 E2 --> P1What changed and why. The beautifier treats each subgraph as a module with its own local flow, then routes the cross-module edges (I2 --> E1, E2 --> P1) as handoffs. The reader sees three rooms, each with an obvious entry and exit — not nine loose nodes that happen to be grouped.
Five techniques you can apply yourself
- Name nodes for their role, not their shape.
[Validate payload]beats[Step 2]. Role-based names let readers scan without chasing edge labels. - Use
subgraphfor modules, not visual grouping. If the group would have a name on an org chart (“Ingest”, “Enrich”), it’s a subgraph. If you’re just clumping nearby nodes to fit a box, don’t — the layout engine already handles proximity. - Label decision edges explicitly. Every
->out of a decision node should carry a label —-->|yes|,-->|no|,-->|retry|. Unlabelled branches force the reader to guess. - Pick the direction that matches the story. Use
TDfor flows with a dominant main path. UseLRwhen the flow has many parallel branches — horizontal space is cheaper than vertical. Composite flows with subgraphs almost always wantTD. - Keep the spine short. If your main path is more than ~8 nodes long, promote a chunk of it into a subgraph. A short, centered spine with named modules reads infinitely better than a 15-node chain.
When to use a tool vs manual tuning
Honest trade-off: for the one diagram on the cover of a critical deck, hand-tune it. Open your flow in a vector editor, nudge each node until the rhythm feels right, and accept that the output won’t regenerate from source. That’s fine for artifacts you ship once.
For anything you ship repeatedly — architecture diagrams in engineering docs, runbook flows in an oncall wiki, sequence overviews in design reviews — keep Mermaid as the source and use a beautifier. The cost of regenerating is zero, and the diagrams stay in sync with the code they describe. Hand-tuned diagrams always drift.
Try it yourself
The fastest way to internalise the techniques above is to paste your own Mermaid flowchart into the editor and toggle between the original render and the beautified one — you’ll see which of your diagrams are already clean and which ones are carrying three of the issues in this guide.