SQL

DDL to ER Diagram

Generates Mermaid ER diagram source from CREATE TABLE statements and their declared foreign keys.

Loading the tool…

Processing happens locally in your browser. What you paste or load is processed by this page and is not uploaded to a server. Nothing is stored unless you use a control that says it stores something, and you can clear anything this site has kept from the privacy page.

How to use this tool

  1. Paste the CREATE TABLE statements for the tables you want on the diagram.
  2. Choose whether relationships should be drawn as optional or mandatory.
  3. Select Generate diagram, then paste the Mermaid source into a document that renders it.

What ddl to erd does

This reads your CREATE TABLE statements and writes Mermaid erDiagram source: one entity per table, its columns with types, and a relationship line for every foreign key the DDL declares. Mermaid renders in GitHub, GitLab, many wikis and most Markdown previewers, so the diagram travels with the document rather than living in a separate drawing file.

Only relationships written into the DDL appear. A foreign key enforced in application code, a soft reference by convention, or a join that exists only inside a query will be missing — not because the diagram is wrong, but because the script never said so. Treat the output as a faithful picture of the DDL, then add what the DDL does not know.

Frequently asked questions

Paste it into a Markdown file in a fenced block marked mermaid. GitHub, GitLab, many wikis and most Markdown editors render it as a diagram, so the picture stays with the document and updates when you regenerate it.

Only foreign keys declared in the DDL are drawn. If a relationship is enforced by application code, or the column is a reference by naming convention only, the script never states it, so it cannot appear on the diagram.

Only roughly. A foreign key tells you the child side is many; whether the parent side is optional depends on the nullability of the key column and on business rules, so you can pick which style to draw and adjust the output by hand.