ER Diagram Maker
Describe entities, columns and relationships and get an entity relationship diagram in crow's foot notation. Good for database schemas, data models and design reviews.
- Diagrams render locally in your browser. Nothing is uploaded to a server.
How it works
Pick a Template (a shop, a blog, a school or a booking system) or start with erDiagram.
Write the relationships first, one per line: CUSTOMER ||--o{ ORDER : places. The two markers state how many of each side can take part.
Add a block per entity to list its columns as type name KEY, using PK, FK and UK for keys.
Download a PNG at 1× to 4× or an SVG, or copy the share link to send the diagram to a colleague.
An entity relationship (ER) diagram shows the tables in a database, the columns that matter and how the tables point at each other. Mermaid draws it in crow's foot notation, where the shape at the end of each line tells you the cardinality: whether one row on this side relates to exactly one, at most one, or many rows on the other. Writing the diagram as text means a schema change is a one-line edit and the diagram can be committed next to your migrations.
ER Diagram Maker syntax cheat sheet
Relationship syntax
A relationship reads LEFT [left marker][line][right marker] RIGHT : label. The markers describe how many rows on that side take part, as seen from the entity on the other side.
| Syntax | Meaning |
|---|---|
|| | Exactly one. |
|o (left) o| (right) | Zero or one. |
}| (left) |{ (right) | One or more. |
}o (left) o{ (right) | Zero or more. |
-- | Identifying relationship: solid line. The child cannot exist without the parent. |
.. | Non-identifying relationship: dashed line. |
A ||--o{ B : has | One A has zero or more B. This is the classic one-to-many. |
A }o--o{ B : "tagged with" | Many to many. Quote the label if it has spaces. |
A ||--o| B : "billed by" | One A has at most one B, a one-to-one that may be empty. |
Entities and attributes
An entity needs no declaration; it exists as soon as a relationship names it. Add a block when you want to show columns.
| Syntax | Meaning |
|---|---|
ORDER { int id PK } | Entity block; one attribute per line, written as type name plus an optional key. |
int customer_id FK | Keys: PK primary, FK foreign, UK unique. Combine them as PK, FK. |
string email UK "login id" | A quoted comment at the end of the line is shown as a note on the attribute. |
p[Person] | Give an entity an alias: referred to as p, shown as Person. |
"Order Line" | Names with spaces must be quoted; underscores are simpler. |
%% comment | Ignored by Mermaid. |
Modelling habits that read well
- Model a many-to-many relationship through a join entity (such as ENROLLMENT between STUDENT and COURSE) with a composite key, as in the school template, when the link has data of its own.
- Use singular, upper-case entity names and a verb in the label so each line reads as a sentence: "CUSTOMER places ORDER".
- List only the columns that explain the model, such as keys and the important attributes. A diagram with every column is a schema dump, not a diagram.
- Check each marker by reading the line aloud from both ends: "one customer places zero or more orders; one order is placed by exactly one customer."
Where the code renders
GitHub, GitLab and Obsidian render ER diagrams from a fenced mermaid code block, so a schema diagram can sit in a README or a docs folder and be reviewed in the same pull request as the migration that changes it. Notion shows them through a code block set to Mermaid. Mermaid draws what you write; it does not read a live database, so keep the diagram and the schema in step by hand, or paste the code in whenever a migration lands. For wiki pages, tickets and slides, export a PNG or SVG.
Text first, not drag and drop
This is a text-first ER diagram maker. There is no canvas to drag tables around, no way to import an existing database and no SQL export. The layout is automatic, which keeps diagrams consistent but means you cannot place two tables side by side by hand. What you get is a schema diagram that is a small text file: easy to diff, easy to keep beside your migrations and quick to edit when a table changes. For reverse-engineering a database or generating DDL, use a database tool.
Export and sharing
Pick copy SVG or download SVG for a sharp vector file, or download PNG at 1×, 2×, 3× or 4× on a white, dark or transparent background. Share link compresses the code with lz-string and puts it in the URL fragment, the part after #, which browsers never send to a server. Your draft is saved in this browser's local storage, separately from the other diagram pages, so a refresh does not lose it. For other diagram types such as class, state, pie, timeline and git graph, use the full Mermaid editor.
Frequently asked questions
Frequently asked questions
How do I read the cardinality symbols?
Each end of a relationship line has a marker: || exactly one, |o or o| zero or one, }| or |{ one or more, }o or o{ zero or more. In CUSTOMER ||--o{ ORDER one customer is linked to zero or more orders.
How do I show primary and foreign keys?
Add an entity block and mark attributes with PK, FK or UK after the name, for example int customer_id FK. A composite key can be written as PK, FK on each of its columns.
How do I draw a many-to-many relationship?
You can draw STUDENT }o--o{ COURSE : attends directly. In a real database that becomes a join table, so models that need to store data on the link (a grade, a date) are clearer with an explicit entity like ENROLLMENT between the two.
Can I generate the diagram from my database or export SQL?
No. This tool draws the text you write and does not connect to a database or produce DDL. If you have a schema, write the relationships you care about, or paste your table list into the editor and shape it into entity blocks.
Is my schema uploaded anywhere?
No. Everything runs in this page. The draft is kept in your browser's local storage, and a share link stores the diagram in the URL fragment, which browsers never send to a server.