← All diagram types
MERMAID DIAGRAM GUIDE

Mermaid ER diagram online editor

Document database entities, fields, relationships, and cardinality. Create the diagram in Mermaid Studio, preview it instantly, and export it when it is ready to share.

WHAT IT IS FOR

Make the important relationships clear

Describe database entities, fields, keys, relationships, and cardinality in a readable ERD that teams can maintain with code.

  • Plan a relational database
  • Document an existing schema
  • Review ownership and cardinality with engineers
Why use Mermaid Studio?
  • Write the source as versionable Mermaid code.
  • Preview changes immediately in the browser.
  • Export the finished diagram as SVG or PNG.
  • Start from a related template when you need a head start.

MERMAID EXAMPLE

Start with a working example

Copy the structure, replace the labels with your own domain, and continue in the full editor.

erDiagram
  USER ||--o{ PROJECT : owns
  PROJECT ||--o{ REVISION : contains
  USER {
    string id PK
    string email
  }
  PROJECT {
    string id PK
    string ownerId FK
    string title
  }

HOW TO START

Create your diagram in four steps

  1. 1Identify the entities and their boundaries.
  2. 2Add primary and foreign key fields.
  3. 3Connect entities with the correct cardinality.
  4. 4Compare the diagram with the schema before implementation.

WRITING TIPS

Keep the diagram useful

Mark primary and foreign keys clearly.

Use Mermaid cardinality symbols for each relationship.

FAQ

Frequently asked questions

What is an ER diagram used for?+

An entity-relationship diagram is used to plan and explain how database entities relate to one another.

Can Mermaid ER diagrams show primary keys?+

Yes. Mermaid ER syntax supports field attributes so primary keys, foreign keys, and other important fields can be documented.

Ready to make a ER?

Open the editor with a working example and adapt it to your project.

Start in Mermaid Studio