readable-mermaid: Automatic readability optimization for Sequence Diagram
#7761
missmoss
started this conversation in
Show and tell
Replies: 1 comment
-
|
Configurable Fixing this requires a bug fix, not some post-processing CLI. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Complex diagrams are unreadable at default settings — a case for automatic readability optimization
The problem
For simple diagrams (≤4 participants, short labels), Mermaid's default rendering is perfectly fine. But once a diagram exceeds ~5-6 components, the output becomes very difficult to read. Text shrinks, spacing gets tight, and the diagram requires zooming and horizontal scrolling to parse.
Here's a fairly typical sequence diagram — 10 participants, 20 messages, nothing extreme by real-world standards:
Paste that into the Mermaid Live Editor and try reading it at normal zoom. The text is barely legible.
This matters because these are exactly the diagrams that show up in real technical design documents — and in my experience, reviewers often skip over them because the cognitive cost of zooming and panning is too high.
Why existing tools focus on aesthetics, not readability
The current ecosystem offers themes, color palettes, and visual editors. These improve how a diagram looks, but they don't address the core issue: text is too small to read at normal zoom when the diagram has more than a handful of components. Most editors don't even expose font size as a configurable option.
There's a technical reason for this. Changing colors is stateless — swapping a hex code doesn't affect any other element's position. But the moment you touch font size or spacing, elements start affecting each other: larger text may overlap adjacent arrows, wider nodes may collide with neighbors, taller headers shift lifeline start positions. It's a cascading layout problem, and it's much harder to solve than theming. A naive "just make the font bigger" on the SVG doesn't work — things overlap immediately.
A different approach: render from source with readability-first layout
Instead of patching Mermaid's SVG output,
readable-mermaidparses the.mmdsource directly and renders it with a custom layout engine built for readability. It doesn't use the Mermaid library at render time — just the.mmdsyntax as input format.The approach:
.mmdsource directly and render with its own layout logic, rather than patching Mermaid's SVG output. This means spacing, font sizes, and element positioning are all computed for readability from the start.The tool
readable-mermaid— a zero-config CLI. One command in, doc-ready SVG and PNG out. Runs locally using your system's installed Chrome, no network calls.[readable-mermaid REPO LINK]
Would love to hear if others have run into this, and whether there's been discussion about a post-render readability pass as part of the Mermaid pipeline.
Beta Was this translation helpful? Give feedback.
All reactions