Free · No sign-up · No watermark

ER diagram templates

Every template here is a piece of Mermaid code that renders as it is: entities, fields, primary and foreign keys and relationships are written out. Replace the table and field names with yours and export to Word, PowerPoint or a high-resolution PNG. Free, no sign-up, no watermark.

Ready-made ER diagram templates

Open one for the preview and the full code, and download PNG, SVG, Word or PowerPoint right there; “Open in the editor” lets you edit the text and pick a theme before exporting.

Three steps to a finished diagram

  1. 1Click "Open the example and edit it" above, or open the template closest to your domain in the editor
  2. 2Rename entities and fields in the code; for a new table add another "NAME { fields }" block and one relationship line. Or send the prompt below to an AI assistant with your tables and paste its whole reply
  3. 3Pick a theme; use the 3× PNG or SVG in a report, or Export to PowerPoint for a presentation

How to write an ER diagram in Mermaid

Try it: copy this and paste it into the editor to render it.

mermaid
erDiagram
    USER ||--o{ ORDER : places
    ORDER ||--|{ ORDER_ITEM : contains
    PRODUCT ||--o{ ORDER_ITEM : "is ordered in"
    USER {
        int id PK
        string name
        string email
    }
    ORDER {
        int id PK
        int user_id FK
        datetime created_at
        decimal total
    }
    ORDER_ITEM {
        int order_id FK
        int product_id FK
        int quantity
    }
    PRODUCT {
        int id PK
        string title
        decimal price
    }
  • Start with erDiagram. Write each entity as "NAME { type field }" with one field per line; add PK after a primary key and FK after a foreign key
  • A relationship reads USER ||--o{ ORDER : places: the symbols at each end are the cardinality and the text after the colon names the relationship
  • Cardinality symbols: || exactly one, o| zero or one, }| one or more, }o zero or more. They are mirrored on the left and right ends
  • Letters, digits and underscores are the safest for names; for a display name write USER["Customer"], and add a comment in double quotes after a field

Ask an AI for your own version with this structure

Send the prompt below to ChatGPT or Claude with the parts in [brackets] replaced by yours, then paste the whole reply into the editor; the code inside is detected automatically.

prompt.txt
Draw a database ER diagram with Mermaid erDiagram syntax. The system is [system name] with these entities: [user, order, product, ...]. List the main fields of each entity as "type name", mark primary keys with PK and foreign keys with FK. The relationships are: [a user has many orders; an order contains many products; ...]. Use cardinality symbols such as ||--o{ and split many-to-many relationships into a junction table. Output only the mermaid code block.

Frequently asked questions

How do I show one-to-many and many-to-many relationships?
One-to-many is A ||--o{ B: one A has zero or more B. In a relational database many-to-many becomes a junction table, so draw A ||--o{ A_B and B ||--o{ A_B: three tables and two lines.
How much detail should an ER diagram in a report have?
Usually every core entity, its main fields with primary and foreign keys marked, and the relationships with their cardinality. Pure logging or configuration tables can be left out. Follow your course or team template where there is one.
Can I draw a Chen-style ER diagram with rectangles, ovals and diamonds?
Mermaid erDiagram uses crow's foot notation: an entity is a table with fields and the line ends show cardinality. If Chen notation is required, draw it with flowchart syntax: rectangles for entities, rounded nodes for attributes and diamonds for relationships.
Can I generate an ER diagram from CREATE TABLE statements?
Send the CREATE TABLE statements to an AI assistant and ask it to convert them to Mermaid erDiagram code, then paste the whole reply into the editor. The prompt on this page can be adapted for that.
Do I have to write field types?
Each field in erDiagram takes a type and a name, such as int, string or datetime; the types are not validated strictly. If you do not want fields shown, entity names and relationships alone still render.

Related