ER Diagram Generator
Describe your tables, keys and relationships as Mermaid erDiagram code and see the ER diagram instantly.
Processed locally in your browser/ Your data stays in your browser.
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?
- Define relationships as "CUSTOMER ||--o{ ORDER : places" (left entity, cardinality, right entity, label).
- Add an attribute block per entity: type, name, and optional PK, FK or UK.
- Choose a theme and check the rendered diagram.
- 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.
Related tools
Mermaid Live Editor
A free-form Mermaid editor: type diagram-as-code and get a live rendered diagram you can export.
Markdown & Diagrams
Class Diagram Generator
Write classDiagram code with classes, members and relations and see the UML diagram immediately.
Markdown & Diagrams
Flowchart Generator
Describe a process one step chain per line and get a flowchart plus the Mermaid code behind it.
Markdown & Diagrams
JSON to TypeScript
Paste a JSON sample and get ready-to-use TypeScript declarations that describe its shape.
JSON & Data
CSV Viewer
Paste CSV text or open a .csv file and inspect it as a table, with row and column counts and the detected delimiter.
JSON & Data
Sequence Diagram Generator
Write one message per line and see who talks to whom, in order, as a sequence diagram.
Markdown & Diagrams