← All updates

Class diagrams now label their relations and multiplicities

Mermaid class diagrams draw the relation label on the line and both multiplicity labels, one at each end — syntax that used to be silently dropped.

mermaidmarkdowndiagrams

Class diagrams have always accepted the two pieces of Mermaid syntax that carry the most meaning on a relation, and then thrown them away. Animal --> Vet : treats drew the line but no "treats", and Owner "1" o-- "*" Animal drew only one of the two numbers — on the wrong side of the edge. Both now render.

The relation label goes on the routed line itself, centred over a page-colour knock-out so the line does not run through the text. It is the same treatment flowchart edge labels already used, so a labelled class diagram and a labelled flowchart look like they came from the same tool.

The multiplicities get one label at each end of the relation, offset to opposite sides of the line so a short edge does not stack them on top of each other. That is what "1" and "*" mean in UML — the cardinality at each end — so Document "1" --> "*" Page now reads as one document to many pages instead of a single floating number.

Nothing changes for diagrams that do not use labels: existing class diagrams render exactly as before. The regenerated samples and the /mermaid/class syntax reference are updated to match.