Mermaid for

Class diagrams

Model your code before you write it

Design object models, define relationships, and document your architecture in a format that lives next to your code.

What is a class diagram?

A class diagram is a UML structural diagram that shows the classes in a system, their attributes and methods, and the relationships between them. The Object Management Group adopted UML (Unified Modeling Language) as a standard in 1997, and the class diagram is one of its most widely used diagrams.

Class diagrams are used for upfront design and for documenting existing codebases. In Mermaid, you write them as text with classDiagram. Mermaid supports inheritance, composition, aggregation, association, dependency, and realization; multiplicity labels such as 1 and 0..*; generics; visibility markers; annotations such as <<interface>>; and namespaces.

What you can map
with a class diagram

Object-oriented system design

Domain model documentation

API resource structures

Inheritance and interface hierarchies

Database ORM layer design

Microservice data contracts

Framework and library architecture

Object-oriented system design

Domain model documentation

API resource structures

Inheritance and interface hierarchies

Database ORM layer design

Microservice data contracts

Framework and library architecture

Who uses class diagrams
on Mermaid

Developers

Design your object model before writing it, or document an existing codebase so the structure is visible.

System Architects

Define the domain model and class structure at the design stage, before implementation begins.

Tech Leads

Review class design in architecture discussions and PRs with a shareable diagram that’s always current.

Data Analysts

Understand and document the structure of an ORM or data model in a format that’s easier to read than raw code.

Consultants

Audit or redesign a client’s software architecture with a diagram that bridges business and technical stakeholders.

When a class diagram is
the right call

Less time syncing, more time building

One shared canvas for mapping ideas, collaborating live, and keeping teams on the same page, literally.

FAQ

Common questions about building class diagrams in Mermaid.

FAQ Icon