Skip to content

ER Diagram Generator

Describe your tables, keys and relationships as Mermaid erDiagram code and see the ER diagram instantly.

Processed locally in your browser

Options
0 chars · 0 lines
The result will appear here.

What is ER Diagram Generator?

An entity-relationship (ER) diagram documents the structure of a database: entities (tables), their attributes with types and key markers, and the relationships between them with cardinality such as one-to-many or many-to-many.

This tool renders Mermaid erDiagram code. The sample models customers, orders, products and line items with PK, FK and UK markers and relationship labels. Cardinality is written with crow's-foot notation such as ||--o{ ("one to zero or many"). Errors are reported with the line and the expected token, and the theme option changes the colors.

How does it work?

  1. Define relationships as "CUSTOMER ||--o{ ORDER : places" (left entity, cardinality, right entity, label).
  2. Add an attribute block per entity: type, name, and optional PK, FK or UK.
  3. Choose a theme and check the rendered diagram.
  4. Export SVG or PNG for schema documentation, or copy the Mermaid source.

Common use cases

  • Documenting a database schema for a README or onboarding guide.
  • Discussing a new data model during design review.
  • Preparing an ER figure for a course assignment or thesis.
  • Keeping a diagram-as-code version of the schema next to migrations.

Examples

Try this input in the tool above:

erDiagram
    CUSTOMER ||--o{ ORDER : places
    ORDER ||--|{ LINE_ITEM : contains
    PRODUCT ||--o{ LINE_ITEM : "is listed in"
    CUSTOMER {
        int id PK
        string name
        string email UK
    }
    ORDER {
        int id PK
        date created_at
        int customer_id FK
    }
    PRODUCT {
        int id PK
        string title
        float price
    }
    LINE_ITEM {
        int order_id FK
        int product_id FK
        int quantity
    }

Privacy

ER Diagram Generator runs entirely in your browser. The text or files you provide are processed on your device and are not uploaded, logged or stored on our servers.

Limitations

The diagram is written by hand: this tool does not read a live database or SQL DDL. Mermaid supports attribute types, keys and comments but not every SQL constraint.

Frequently asked questions

How do I read ||--o{ ?

Each end shows a minimum and maximum: || is exactly one, o| zero or one, }o zero or many, }| one or many. So ||--o{ reads "exactly one to zero or many".

How do I mark primary and foreign keys?

Add PK, FK or UK after the attribute name inside the entity block, for example "int customer_id FK".

Can I use spaces in relationship labels?

Yes, but put the label in double quotes: PRODUCT ||--o{ LINE_ITEM : "is listed in". Entity names should avoid spaces.

More tools in Markdown & Diagrams →