ER Diagram

Free Online ER Diagram Tool

Design database schemas and entity relationships using Mermaid syntax. Instant visual preview as you type.

Try it live

erDiagram
    USER {
        int id PK
        string email UK
        string name
        datetime created_at
        bool is_active
    }
    PRODUCT {
        int id PK
        string name
        decimal price
        int stock
        int category_id FK
    }
    ORDER {
        int id PK
        int user_id FK
        decimal total
        string status
        datetime ordered_at
    }
    ORDER_ITEM {
        int id PK
        int order_id FK
        int product_id FK
        int quantity
        decimal unit_price
    }
    CATEGORY {
        int id PK
        string name
    }

    USER ||--o{ ORDER : "places"
    ORDER ||--|{ ORDER_ITEM : "contains"
    PRODUCT ||--o{ ORDER_ITEM : "included in"
    CATEGORY ||--o{ PRODUCT : "has"

When to use er diagram

Database design

Plan and document relational database schemas before writing migrations.

API documentation

Show the data model underlying your API resources and their relationships.

System documentation

Communicate data structure to new team members and stakeholders.

Key syntax

erDiagramDeclare diagram type
ENTITY { }Define an entity with attributes
int id PKPrimary key attribute
int fk FKForeign key attribute
string email UKUnique key attribute
A ||--|| BOne-to-one relationship
A ||--o{ BOne-to-many relationship
A }o--o{ BMany-to-many relationship
: "label"Relationship label

How to create a er diagram with Mermaid

1

Open FlowViz and start with erDiagram.

2

Define each entity with its name and an opening brace: USERS {.

3

Add attributes inside the braces: type name constraint (e.g. int id PK).

4

Close each entity with }.

5

Define relationships between entities on new lines: USER ||--o{ ORDER : "places".

6

Use || for exactly one, o{ for zero or many, |{ for one or many.

7

Add a quoted label after the colon to describe the relationship.

8

Export your schema diagram as SVG.

Start diagramming now

No signup. No install. Just open the editor and start writing.