SQL DDL to ER Diagram

Inspect supported SQL table definitions and export a diagram of declared relationships.

On-device No sign-up Free to use

Inspect input controls

Showing an example. Edit to see your own.

?

A strict PostgreSQL-like subset: 100,000 UTF-8 bytes, 12 tables, 120 columns and 40 declared foreign keys.

Processed in your browser. Your inputs stay on this device.

Result

Showing an example.

Diagram customers and orders with one declared customer_id foreign key.

Diagrammed 2 tables and 1 declared foreign key.

Loading the tool. Your result will appear here.

https://usefreetools.net/sql-ddl-er-diagram · 20 November 2026

Was this helpful?

How to use SQL DDL to ER Diagram

  1. Paste supported CREATE TABLE declarations, including every referenced table.
  2. Declare foreign keys explicitly. Referenced columns must exist and match an ordered PRIMARY KEY or UNIQUE group in the supplied declarations.
  3. Read the declared-key report. Download schema-diagram.svg, schema-diagram.mmd and schema-name-map.json as needed.
  4. Keep the name map with Mermaid edits, and review the original SQL separately before running any database change.

Example: SQL DDL to ER Diagram

Diagram customers and orders with one declared customer_id foreign key.

You add
CREATE TABLE declarations: CREATE TABLE customers (id INTEGER PRIMARY KEY, name VARCHAR(100) NOT NULL); CREATE TABLE orders (id INTEGER PRIMARY KEY, customer_id INTEGER REFERENCES customers(id), total DECIMAL(10,2));
You get
Diagrammed 2 tables and 1 declared foreign key.

Options

Column and key subset
Use plain INT/INTEGER, SMALLINT, BIGINT, REAL, DOUBLE PRECISION, NUMERIC, DECIMAL, CHAR, VARCHAR, TEXT, BOOLEAN, DATE, TIMESTAMP, UUID or BYTEA types. Supported declarations include NOT NULL and primary, unique or foreign keys, including grouped keys. Unknown clauses are refused.
Declared relationships
Foreign-key declarations create diagram edges. Similar column names do not create relationships, and the tool does not infer cardinality, optionality or data counts. Include both sides of each relationship in the supplied SQL.
Diagram exports
The SVG shows original names. Mermaid uses class-diagram syntax and generated table/field identifiers; schema-name-map.json maps them back to the original names. These exports do not create or migrate a database.

Supported inputs and limits

  • A strict PostgreSQL-like CREATE TABLE subset: up to 100,000 UTF-8 bytes, 12 tables, 120 total columns, 40 foreign keys and 12,000 tokens.
  • Identifiers accept a bounded ASCII grammar; schema-qualified names, backticks, defaults, CHECK, named constraints, generated expressions, indexes, ALTER and dialect options are refused.
  • SVG height is limited to 8,000 pixels and combined SVG/Mermaid source to 1,000,000 UTF-8 bytes.
  • No SQL runs, database connection, full dialect validation or inferred cardinality is provided.

Where your input is processed

This tool does not upload your inputs. See the limits for anything saved on your device.

Keep original names with the diagram

The SVG displays original names, while Mermaid uses generated identifiers and a separate name map. Include that mapping when adapting the Mermaid source. A relationship picture can help review a schema draft, but it does not run migrations, inspect existing data or prove that a database currently enforces the constraints.

Questions about SQL DDL to ER Diagram

Does this run the SQL?

No. It reads supported declarations in the browser.

Are all database dialects supported?

No. Unsupported types, constraints or statement forms are refused.

Where do the relationship lines come from?

Only declared foreign keys create relationships; the tool does not infer row counts or business rules.

Page updated · Project managed by Tony Hines · Report a problem with SQL DDL to ER Diagram