Advanced

SQL Relationship Diagram Generator

Paste CREATE TABLE statements and get a simple visual diagram of tables, keys and foreign-key relationships.

Advertisement

About this tool

This parses CREATE TABLE statements to find each table's name, columns, primary key and foreign keys, then draws a simple entity-relationship diagram with lines connecting each foreign key to the primary key it references. It recognises both common ways of writing a foreign key: the inline shorthand (customer_id INT REFERENCES customers(id)) and the explicit constraint form (FOREIGN KEY (customer_id) REFERENCES customers(id)), including with a CONSTRAINT name in front. Table names can have a schema prefix (dbo.orders) and be quoted in any style, comments are ignored, and a table that references itself, such as manager_id pointing at employees.id, gets a loop on its own box. Foreign-key columns are marked (FK), and boxes widen to fit long column names and types. Use Download SVG to save the diagram for documentation or a slide.

Scope: this is a best-effort, text-scanning parser — not a full SQL grammar parser for every dialect. It handles common, reasonably-formatted CREATE TABLE statements well, but unusual formatting, vendor-specific extensions, or deeply nested constraint syntax may not parse perfectly. Table boxes are arranged in a simple fixed grid rather than an auto-layout algorithm, so lines can cross on more complex schemas — treat the diagram as a quick visual aid, not a publication-ready ER diagram.