ER Diagram Generator

An entity relationship diagram (ERD) models the data in a system: the entities (usually database tables), their attributes (columns), and the relationships between them. ER diagrams are the standard way to design and document a relational schema before you write a single line of SQL, and to communicate that schema to the rest of a team.

Diagramming AI turns a plain-English description of your data into an editable Mermaid ER diagram in seconds. Describe the entities and how they relate — "a customer places many orders, each order has many line items" — and the AI generates ready-to-edit ER diagram code complete with keys and cardinality, which you can then refine conversationally.

What is an entity relationship diagram?

An ER diagram represents each entity as a box containing its attributes. Attributes can be marked as a primary key (PK), which uniquely identifies a row, or a foreign key (FK), which references the primary key of another entity. The lines between entities express relationships, and the symbols at each end (known as crow’s-foot notation) express cardinality — whether a relationship is one-to-one, one-to-many, or many-to-many.

Reading crow’s-foot notation: a single bar means "one", a circle means "zero", and the three-pronged "crow’s foot" means "many". So a connector that reads "one-and-only-one" on one side and "zero-or-many" on the other captures a classic one-to-many relationship such as a customer who may have any number of orders.

How to create an ER diagram with AI

Start by listing your entities and the key attributes of each, then describe how they relate in plain language. Mention which fields are identifiers and which reference other tables. Diagramming AI converts that description into Mermaid ER diagram code, inferring sensible primary and foreign keys and the correct cardinality.

From there, iterate in the chat: "add a payments table linked to orders", "make the relationship between users and profiles one-to-one", or "add a created_at timestamp to every table". Each instruction updates the editable diagram code, and you can export the result or paste the Mermaid into your project documentation.

ER diagram examples

E-commerce orders schema

Scenario: A classic online-store data model: customers place orders, orders contain line items, and line items reference products. Demonstrates one-to-many relationships and a join entity.

Instruction text for AI

Create an ER diagram for an e-commerce store: a customer can place many orders, each order contains many order items, and each order item references one product. Include primary keys, foreign keys, and useful attributes on each table.

Generated Diagram (Mermaid)

erDiagram
    CUSTOMER ||--o{ ORDER : places
    ORDER ||--|{ ORDER_ITEM : contains
    PRODUCT ||--o{ ORDER_ITEM : "ordered in"

    CUSTOMER {
        int id PK
        string email
        string full_name
        datetime created_at
    }
    ORDER {
        int id PK
        int customer_id FK
        string status
        decimal total
        datetime created_at
    }
    ORDER_ITEM {
        int id PK
        int order_id FK
        int product_id FK
        int quantity
        decimal unit_price
    }
    PRODUCT {
        int id PK
        string name
        decimal price
        int stock
    }

Blog with users, posts, and comments

Scenario: A content model where users author posts and readers leave comments, showing two one-to-many relationships off a central entity.

Instruction text for AI

Draw an ER diagram for a blog: a user can write many posts, a post can have many comments, and each comment is written by a user. Add primary and foreign keys and timestamps.

Generated Diagram (Mermaid)

erDiagram
    USER ||--o{ POST : writes
    POST ||--o{ COMMENT : has
    USER ||--o{ COMMENT : authors

    USER {
        int id PK
        string username
        string email
    }
    POST {
        int id PK
        int author_id FK
        string title
        text body
        datetime published_at
    }
    COMMENT {
        int id PK
        int post_id FK
        int user_id FK
        text body
        datetime created_at
    }

Many-to-many with a join table

Scenario: Students enrol in many courses and each course has many students — the canonical many-to-many relationship resolved through an ENROLLMENT join entity.

Instruction text for AI

Generate an ER diagram for a school where students can enrol in many courses and each course can have many students. Use an enrollment join table that records the grade and enrollment date.

Generated Diagram (Mermaid)

erDiagram
    STUDENT ||--o{ ENROLLMENT : has
    COURSE ||--o{ ENROLLMENT : has

    STUDENT {
        int id PK
        string name
        string email
    }
    COURSE {
        int id PK
        string title
        int credits
    }
    ENROLLMENT {
        int id PK
        int student_id FK
        int course_id FK
        string grade
        date enrolled_on
    }

Frequently asked questions

What is an ER diagram used for?

ER diagrams are used to design and document relational databases. They show the entities (tables), their attributes (columns), the primary and foreign keys, and the relationships and cardinality between entities. Teams use them to plan a schema before implementation and to keep a shared understanding of how data is structured.

Can I generate an ER diagram from text?

Yes. Describe your entities and how they relate in plain English, and Diagramming AI generates an editable Mermaid ER diagram with primary keys, foreign keys, and crow’s-foot cardinality. You can then refine it through follow-up chat instructions and export the result.

What is crow’s-foot notation?

Crow’s-foot notation is the most common way to show cardinality in an ER diagram. A bar means "one", a circle means "zero", and the three-pronged foot means "many". Combining these at each end of a relationship expresses one-to-one, one-to-many, and many-to-many relationships. Mermaid ER diagrams use this notation by default.

How do I model a many-to-many relationship?

A many-to-many relationship is modeled with a join (or associative) entity placed between the two tables. For example, students and courses connect through an enrollment table that holds a foreign key to each side plus any relationship-specific data such as a grade. Diagramming AI creates the join table automatically when you describe a many-to-many relationship.