Layout-fidelity scorecard

How closely our flowchart, state, class and ER layouts match official mermaid.js: the share of node pairs placed in the same above/below/beside relation (vertical, horizontal) and of node/subgraph pairs that agree on containment. Only relative placement is compared. Each sample has an explicit floor for its lowest figure (default 85%, lower overrides in SAMPLE_FLOORS); --thresholds exits 1 on a breach. Floors guard against regressions, they do not claim parity. Method: scripts/layout-oracle.ts.

Reference: mermaid 12.2.0. Since mermaid 12.0.0 its default layout engine for these diagram types is ELK (it was dagre before). Generated 2026-11-02 at ae439b3 with pnpm run layout:scorecard, tolerance 20px.

Latest run (means over samples)

TypeSamplesVerticalHorizontalContainment
Flowchart56100%98%100%
State7100%98%100%
Class29100%100%100%
ER20100%100%-

Trend (last 20 recorded runs)

Runs recorded before 12.1.0 were measured against mermaid 11.17.2 (dagre) and cover flowcharts only. The reference changed engine, so do not read a trend across that change.

DateCommitMermaidTypeSamplesVerticalHorizontalContainment
2026-10-30036684d12.2.0Flowchart53100%98%100%
2026-10-30036684d12.2.0State7100%98%100%
2026-10-30036684d12.2.0Class29100%100%100%
2026-10-30036684d12.2.0ER20100%100%-
2026-10-30151f85312.2.0Flowchart53100%98%100%
2026-10-30151f85312.2.0State7100%98%100%
2026-10-30151f85312.2.0Class29100%100%100%
2026-10-30151f85312.2.0ER20100%100%-
2026-10-31ac52e8a12.2.0Flowchart53100%98%100%
2026-10-31ac52e8a12.2.0State7100%98%100%
2026-10-31ac52e8a12.2.0Class29100%100%100%
2026-10-31ac52e8a12.2.0ER20100%100%-
2026-10-3167dd7ff12.2.0Flowchart53100%98%100%
2026-10-3167dd7ff12.2.0State7100%98%100%
2026-10-3167dd7ff12.2.0Class29100%100%100%
2026-10-3167dd7ff12.2.0ER20100%100%-
2026-11-02ae439b312.2.0Flowchart56100%98%100%
2026-11-02ae439b312.2.0State7100%98%100%
2026-11-02ae439b312.2.0Class29100%100%100%
2026-11-02ae439b312.2.0ER20100%100%-

Edge labels (ASCII)

Where an edge label sits between its two nodes (0 = source end, 1 = target end; official mermaid centres it at about 0.5), averaged over the cases in scripts/label-position-oracle.ts. Delta is the mean absolute difference between the two renderers. Descriptive only, no floor.

DateCommitMermaidCasesOfficialASCIIDelta
2026-10-27a70ae2e12.2.040.500.530.06
2026-10-30507a22612.2.040.500.530.06
2026-10-3079a012512.2.040.500.530.06
2026-10-30961cbfa12.2.040.500.530.06
2026-10-30036684d12.2.040.500.530.06
2026-10-30151f85312.2.040.500.530.06
2026-10-31ac52e8a12.2.040.500.530.06
2026-10-3167dd7ff12.2.040.500.530.06
2026-11-02ae439b312.2.040.500.530.06

Sequence diagrams (order)

Sequence has no layout engine to compare, so the share of agreeing pairs is taken for participant left-to-right order and message top-to-bottom order, and the share of messages pointing the same way (scripts/sequence-oracle.ts). Every sample must score 100% (SEQUENCE_FLOOR; --thresholds exits 1 otherwise), so this guards against regressions in a grid that agrees today. It says nothing about pixel positions or spacing.

DateCommitMermaidSamplesParticipantsMessagesDirection
2026-10-30507a22612.2.021100%100%100%
2026-10-3079a012512.2.021100%100%100%
2026-10-30961cbfa12.2.021100%100%100%
2026-10-30036684d12.2.021100%100%100%
2026-10-30151f85312.2.021100%100%100%
2026-10-31ac52e8a12.2.021100%100%100%
2026-10-3167dd7ff12.2.021100%100%100%
2026-11-02ae439b312.2.024100%100%100%

Pie charts (angles)

A pie has no nodes, so the share of drawn slices whose start and sweep angle agree (within ANGLE_TOLERANCE), of slices printing the same percentage and of legend rows with the same text is taken (scripts/pie-oracle.ts). Slices are matched by position, so a different slice order counts as an angle disagreement. Every sample must score 100% (PIE_FLOOR; --thresholds exits 1 otherwise). It says nothing about radius, centre or fonts.

DateCommitMermaidSamplesAnglesLabelsLegend
2026-10-3079a012512.2.019100%100%100%
2026-10-30961cbfa12.2.019100%100%100%
2026-10-30036684d12.2.019100%100%100%
2026-10-30151f85312.2.019100%100%100%
2026-10-31ac52e8a12.2.019100%100%100%
2026-10-3167dd7ff12.2.019100%100%100%
2026-11-02ae439b312.2.019100%100%100%

C4 diagrams (placement)

C4 has no layout engine to compare, so the share of box pairs on the same side of each other (columns and rows, within PLACE_TOLERANCE), of boxes inside the same boundaries, of relationships with the same label and technology text and of relationships running the same way is taken (scripts/c4-oracle.ts). Every sample must score 100% (C4_FLOOR; --thresholds exits 1 otherwise) except those held lower in C4_SAMPLE_FLOORS, where our placement really differs. It says nothing about box sizes or fonts.

DateCommitMermaidSamplesHorizontalVerticalContainmentRelationshipsDirection
2026-10-30961cbfa12.2.0391%93%100%100%93%
2026-10-30036684d12.2.0391%93%100%100%93%
2026-10-30151f85312.2.0391%93%100%100%93%
2026-10-31ac52e8a12.2.0391%93%100%100%93%
2026-10-3167dd7ff12.2.0391%93%100%100%93%
2026-11-02ae439b312.2.03100%100%100%100%100%

XY charts (axes and data)

An xychart has no nodes, so the share of axis labels with the same text, of axis labels at the same fraction of their axis and of bars and line points at the same category and value fraction is taken (scripts/xychart-oracle.ts). Positions are fractions of the axis, so canvas size does not count. Every sample must score 100% (XYCHART_FLOOR; --thresholds exits 1 otherwise). It says nothing about colors, fonts or bar widths.

DateCommitMermaidSamplesLabelsTicksData
2026-10-30036684d12.2.010100%100%90%
2026-10-31ac52e8a12.2.010100%100%90%
2026-10-3167dd7ff12.2.010100%100%90%
2026-11-02ae439b312.2.010100%100%100%

Architecture diagrams (placement)

Mermaid places architecture services with cytoscape fcose, constrained by the L/R/T/B sides in the source. A force layout moves with its seed and font metrics, so only relative placement is scored: the share of service pairs above / below / beside each other and of (service, group) pairs agreeing on containment, with services within ARCH_TOLERANCE (half an icon) counted as level (scripts/architecture-oracle.ts). Every sample must stay at or above ARCH_FLOOR (--thresholds exits 1 otherwise), a regression guard, not a parity claim. It says nothing about distances or edge routes.

DateCommitMermaidSamplesVerticalHorizontalContainment
2026-10-30151f85312.2.0368%84%97%
2026-10-31ac52e8a12.2.0368%84%97%
2026-10-3167dd7ff12.2.0368%84%97%
2026-11-02ae439b312.2.0374%90%97%

Per sample

Flowchart (lowest first)

SampleVerticalHorizontalContainmentNodesFloorStatus
Flowchart: Self-Loop with In and Out Neighbours (TD)100%33%-330%pass
Flowchart: Dense Duplicate Edges (TD)100%67%-365%pass
System Architecture89%100%100%1085%pass
Fan-Out Under Half-Column Parent100%97%-985%pass
Simple Flow100%100%-385%pass
Original Node Shapes100%100%-585%pass
Subroutine and Hexagon Shapes100%100%-385%pass
Cylinder and Trapezoid Shapes100%100%-485%pass
Twelve Core Flowchart Shapes100%100%-1285%pass
All Edge Styles100%100%-485%pass
No-Arrow Edges100%100%-485%pass
Text-Embedded Labels100%100%-585%pass
Bidirectional Arrows100%100%-485%pass
Parallel Links (&)100%100%-585%pass
Chained Edges100%100%-585%pass
linkStyle: Color-Coded Edges100%100%-585%pass
linkStyle: Default + Override100%100%-585%pass
Direction: Left-Right (LR)100%100%-385%pass
Direction: Bottom-Top (BT)100%100%-385%pass
Subgraphs100%100%100%485%pass
Nested Subgraphs100%100%100%595%pass
Subgraph Direction Override100%100%100%685%pass
::: Class Shorthand100%100%-385%pass
Inline Style Overrides100%100%-385%pass
CI/CD Pipeline100%100%100%785%pass
Decision Tree100%100%-785%pass
Git Branching Workflow100%100%-785%pass
Interactivity: Links and Tooltips100%100%-385%pass
Interactivity: Animated Edge100%100%-385%pass
Labeled Fan-In (LR)100%100%-485%pass
Direction: Right-Left (RL)100%100%-485%pass
Nested Subgraphs (RL)100%100%100%485%pass
Nested Subgraphs (BT)100%100%100%485%pass
Edges Into and Out of Subgraphs100%100%100%885%pass
Vertical Edge Labels100%100%-585%pass
Flowchart: CJK Labels100%100%100%495%pass
Flowchart: Three Parallel Edges (TD)100%100%-285%pass
Flowchart: Three Parallel Edges Plus Reciprocal (TD)100%100%-285%pass
Flowchart: Four Parallel Edges (TD)100%100%-285%pass
Flowchart: Five Cluster Exit Siblings (TD)100%100%100%485%pass
LR Fan-In With Bypass Edge100%100%-385%pass
Reciprocal and Duplicate Edges RL100%100%-285%pass
Decision Self-Loop with Duplicate Edges100%100%-485%pass
LR Bypass Edge In A Chain100%100%-485%pass
Flowchart: Five Parallel Edges (TD)100%100%-285%pass
Flowchart: Five Parallel Edges with Reciprocals (LR)100%100%-285%pass
Flowchart: Six Cluster Exit Siblings (TD)100%100%100%485%pass
Flowchart: Parallel Edges with Back Edges (TD)100%100%-285%pass
Flowchart: Cluster Exit Siblings with No Other Exit (TD)100%100%100%385%pass
Flowchart: Nine Cluster Exit Siblings (TD)100%100%100%485%pass
Flowchart: Self-Loop with In and Out Neighbours (LR)100%100%-385%pass
Flowchart: Dense Duplicate Edges (LR)100%100%-385%pass
Parallelogram Shapes (LR)100%100%-485%pass
Parallelogram Shapes (RL)100%100%-485%pass
Parallelogram Shapes (BT)100%100%-485%pass
Duplicate Self-Loops---185%n/a

State (lowest first)

Not scored (the oracle errored): zombie-mermaid.

SampleVerticalHorizontalContainmentNodesFloorStatus
State: Notes100%83%-480%pass
State: Basic State Diagram100%100%-585%pass
State: Composite States100%100%100%885%pass
State: Connection Lifecycle100%100%-785%pass
State: CJK State Names100%100%-685%pass
State: Choice, Fork and Join100%100%-785%pass
State: Concurrent Regions100%100%100%485%pass

Class (lowest first)

SampleVerticalHorizontalContainmentNodesFloorStatus
Class: Inheritance (<|--)100%100%-395%pass
Class: Composition (*--)100%100%-285%pass
Class: Aggregation100%100%-285%pass
Class: Association (-->)100%100%-285%pass
Class: Dependency (..>)100%100%-285%pass
Class: Realization (..|>)100%100%-285%pass
Class: All 6 Relationship Types100%100%-1285%pass
Class: Relationship Labels100%100%-395%pass
Class: Design Pattern — Observer100%100%-585%pass
Class: MVC Architecture100%100%-395%pass
Class: Full Hierarchy100%100%-695%pass
Class: Namespaces100%100%100%395%pass
Class: classDiagram-v2 Header100%100%-285%pass
Class: Bidirectional Relationships100%100%-485%pass
Class: Lollipop Interface100%100%-285%pass
Class: Backtick Class Names100%100%-285%pass
Class: Mixed Newly Accepted Syntax100%100%-585%pass
Class: Relationship Cardinalities100%100%-485%pass
Class: Cardinalities on Every Relationship Kind100%100%-1285%pass
Class: Cardinalities with Shared Ends100%100%-485%pass
Class: Direction LR100%100%-485%pass
Class: Direction BT100%100%-485%pass
Class: Direction RL with Namespaces100%100%100%385%pass
Class: Two Namespaces with Cross Edges100%100%100%485%pass
Class: Basic Class---185%n/a
Class: Visibility Markers---185%n/a
Class: Interface Annotation---185%n/a
Class: Abstract Annotation---185%n/a
Class: Enum Annotation---185%n/a

ER (lowest first)

SampleVerticalHorizontalContainmentNodesFloorStatus
ER: Basic Relationship100%100%-285%pass
ER: Exactly One to Exactly One (||--||)100%100%-285%pass
ER: Exactly One to Zero-or-Many100%100%-285%pass
ER: Zero-or-One to One-or-Many100%100%-285%pass
ER: One-or-More to Zero-or-Many100%100%-285%pass
ER: All Cardinality Types100%100%-885%pass
ER: Identifying (Solid) Relationship100%100%-285%pass
ER: Non-Identifying (Dashed) Relationship100%100%-385%pass
ER: Mixed Identifying & Non-Identifying100%100%-585%pass
ER: E-Commerce Schema100%100%-485%pass
ER: Blog Platform Schema100%100%-485%pass
ER: School Management Schema100%100%-485%pass
ER: Word-Form Cardinalities and .- / -. Lines100%100%-885%pass
ER: Remaining Cardinality Spellings100%100%-585%pass
ER: Style, classDef and Class100%100%-385%pass
ER: Crossing Edges and Edge Labels100%100%-585%pass
ER: Attribute Comments100%100%-285%pass
ER: Entity with Attributes---185%n/a
ER: Attribute Keys (PK, FK, UK)---185%n/a
ER: Multiple Keys per Attribute---185%n/a

Diagram types not scored

sequence: mermaid draws it on a fixed grid (participants left to right in declaration order, messages top to bottom in source order), not with a layout engine, so node placement says nothing. Order and direction are scored separately, in the Sequence section.

architecture-beta: mermaid places services with cytoscape fcose constrained by the explicit L/R/T/B port sides in the source, a force layout whose distances are not comparable. Relative placement and group containment are scored separately, in the Architecture section.

xychart-beta: no nodes: positions come from axis labels and data values. Label text, tick positions and bar/line data positions are scored separately, in the XY charts section.

pie: no nodes: positions come from data values. Slice angles, percentages and legend rows are scored separately, in the Pie section.

c4: mermaid places C4 boxes on a fixed grid in shape order, not with a layout engine over edges. Box placement, boundary containment and relationships are scored separately, in the C4 section.