01What is ERD Generator?
Getting a schema into a diagram often means opening a desktop modelling app or signing up for a hosted one. This tool skips that step. It reads your DDL or Prisma models and writes Mermaid erDiagram text, which GitHub, GitLab, Notion and many docs sites render on their own. The output follows the entity-relationship syntax in the official Mermaid documentation, including its PK and FK attribute keys. The input type is detected for you. If the text contains a block like model Name {, it is read as Prisma. Scalar fields become columns, and @id or @@id marks the primary key. List fields such as Post[] and back-references to other models are skipped, since they are not real columns. A field with @relation(fields: [...], references: [...]) marks the listed scalar fields as foreign keys and adds a relationship line. Anything else is scanned for CREATE TABLE statements. That covers IF NOT EXISTS, TEMP and UNLOGGED tables, schema-qualified names and quoted names. Columns are split on top-level commas only, so a type like DECIMAL(10,2) stays in one piece. Inline PRIMARY KEY and REFERENCES table(col) clauses are picked up. So are table-level PRIMARY KEY (...) and FOREIGN KEY (...) REFERENCES ... constraints, which get applied back to the matching columns. UNIQUE, CHECK and INDEX lines are skipped. A small example shows the result. Paste a table orders with id BIGINT PRIMARY KEY and user_id INT REFERENCES users(id). You get an orders block listing BIGINT id PK and INT user_id FK, then the line users ||--o{ orders : "user_id". The label on each relation is the foreign-key column name. There are honest limits. Every relationship is drawn as one-to-many, so one-to-one and many-to-many links need a manual edit. Multi-word types keep only their first word, because Mermaid attribute types cannot hold spaces. Schema prefixes are dropped, so public.users and audit.users would merge. This is pattern matching, not a full SQL parser, so unusual dialect syntax can slip past it. The tool shows Mermaid source rather than a picture. Paste it into a Mermaid-aware viewer to see the diagram. Your schema text is parsed in the browser tab and is not uploaded. A summary line shows the table count, relation count and detected syntax, and a Tables list gives each table's column count.
Backend developers and technical writers who want a Mermaid ERD of a SQL or Prisma schema for a README, wiki or code review. The tool runs entirely in your browser, so your data never leaves your device.
02How to use ERD Generator
- Paste CREATE TABLE statements or Prisma models into the SQL or Prisma Schema box, or load the Blog schema, E-commerce or Prisma schema example.
- Check the summary line for the table count, relation count and whether SQL or Prisma was detected.
- Review the Mermaid ERD output and the Tables list with each table's column count.
- Click Copy Mermaid and paste the text into a mermaid code block or the Mermaid Live Editor.
- Adjust the cardinality symbols by hand for any link that is not one-to-many.
03Worked examples
- Input:
CREATE TABLE "public"."orders" ( id BIGINT PRIMARY KEY, user_id INT REFERENCES users(id), total DECIMAL(10,2) NOT NULL ); - Result:
erDiagram orders { BIGINT id PK INT user_id FK DECIMAL(10,2) total } users ||--o{ orders : "user_id" - The schema prefix and quotes are stripped, and the comma inside DECIMAL(10,2) does not split the column.
- Input:
CREATE TABLE order_items ( order_id INT, product_id INT, qty INT, PRIMARY KEY (order_id, product_id), FOREIGN KEY (order_id) REFERENCES orders(id), FOREIGN KEY (product_id) REFERENCES products ); - Result:
erDiagram order_items { INT order_id PK, FK INT product_id PK, FK INT qty } orders ||--o{ order_items : "order_id" products ||--o{ order_items : "product_id" - Table-level PRIMARY KEY and FOREIGN KEY constraints are applied back to the columns, so a join table shows both PK and FK.
- Input:
CREATE TABLE IF NOT EXISTS tags (id SERIAL PRIMARY KEY, labels TEXT[], UNIQUE (id)); - Result:
erDiagram tags { SERIAL id PK TEXT[] labels } - The UNIQUE constraint line is skipped and does not show up as a column. Array types keep their brackets.
- Input:
model User { id Int @id posts Post[] } model Post { id Int @id authorId Int author User @relation(fields: [authorId], references: [id]) } - Result:
erDiagram User { Int id PK } Post { Int id PK Int authorId FK } User ||--o{ Post : "authorId" - In Prisma, relation fields (posts, author) are not columns. The scalar authorId listed in @relation is marked as the foreign key.
- Input:
CREATE TABLE events (id BIGINT PRIMARY KEY, at TIMESTAMP WITH TIME ZONE, score DOUBLE PRECISION); - Result:
erDiagram events { BIGINT id PK TIMESTAMP at DOUBLE score } - Multi-word types keep only their first word, so check the diagram if the exact type matters to your readers.
- Input:
model Like { userId Int postId Int @@id([userId, postId]) } - Result:
erDiagram Like { Int userId PK Int postId PK } - A Prisma composite @@id marks both fields as part of the primary key.
04Common use cases
- Adding a schema diagram to a README or pull request description on GitHub
- Documenting a legacy Postgres database during a handover to another team
- Visualising a Prisma schema before a migration review
- Dropping an ERD into Notion or another wiki that renders Mermaid code blocks
- Checking that every FOREIGN KEY in a migration file points where you think it does
- Explaining table relationships to a new hire using the real DDL rather than a stale drawing
05Tips
- Schema prefixes are dropped (public.users becomes users), so two tables with the same name in different schemas will collide in the diagram.
- Types like DOUBLE PRECISION or TIMESTAMP WITH TIME ZONE are cut to their first word, because Mermaid attribute types cannot contain spaces.
- Prisma implicit many-to-many relations (Post[] on both sides) are not drawn. Add a }o--o{ line yourself if you want one.
- A FOREIGN KEY ... REFERENCES products with no column list is assumed to point at id.
- If your text mentions model Something { anywhere, even in a comment, the whole input is parsed as Prisma.
06Related concepts
Entity-relationship diagram, Mermaid, Foreign keys, Prisma, DDL, Cardinality.
Frequently Asked Questions
What is ERD Generator?
ERD Generator is a free, browser-based developer tool on AIDToolStack. Generate ER diagrams from SQL/Prisma schema It requires no installation or sign-up and works entirely in your browser.
Is ERD Generator free to use?
Yes. No sign-up, no fees and no usage cap.
Does ERD Generator store my data?
No. It runs in your browser; nothing is uploaded.