Diagram type

Mermaid ER diagram editor

Build entity-relationship diagrams in Mermaid and export them for schema reviews, database design, and data model documentation.

Use this page to connect a high-intent search query to the right problem-solution narrative.

At a glance

A Mermaid ER diagram page for teams designing or documenting relational schemas.

Why use a Mermaid ER diagramGood fit forWhen to combine with a class diagram
Rendered proof
ER diagram with users, orders, and line items.
Theme · Brutalist
Open this diagram in editor
JOIN TABLE MODEL places contains referenced_in USER id string PK email string name string ORDER id string PK userId string FK placedAt datetime LINE_ITEM id string PK orderId string FK productId string FK quantity int PRODUCT id string PK name string price decimal
View Mermaid sourcePlain-text diagram syntax — copy or edit directly.
diagram.mmd
1erDiagram
2 USER ||--o{ ORDER : places
3 ORDER ||--|{ LINE_ITEM : contains
4 PRODUCT ||--o{ LINE_ITEM : referenced_in
5 USER {
6 string id PK
7 string email
8 string name
9 }
10 ORDER {
11 string id PK
12 string userId FK
13 datetime placedAt
14 }
15 LINE_ITEM {
16 string id PK
17 string orderId FK
18 string productId FK
19 int quantity
20 }
21 PRODUCT {
22 string id PK
23 string name
24 decimal price
25 }

Why use a Mermaid ER diagram

ER diagrams show entities, their attributes, and the relationships between them, including cardinality. They are a standard tool for database and data-model reviews.

  • Entities with typed attributes
  • Primary and foreign key hints
  • One-to-many and many-to-many relations

Good fit for

Schema review threads, migration plans, data model onboarding, and any discussion that hinges on how records relate.

When to combine with a class diagram

Use an ER diagram for the storage model and a class diagram for the runtime model. Teams often keep both side by side in onboarding docs.

FAQ

Mermaid ER diagram editor — frequently asked questions

When is a Mermaid ER diagram the right fit?

Use it when the main topic is how records relate in a relational schema — primary keys, foreign keys, one-to-many and many-to-many relationships.

How do I show cardinality between entities?

Use notation like `USER ||--o{ ORDER : places`. The symbols describe minimum and maximum cardinality on both sides of the relationship.

Can I include attributes inside an entity?

Yes. Wrap the attribute list in braces, annotate primary keys with `PK` and foreign keys with `FK`, and the editor keeps that formatting in the exported diagram.