Skip to content
cosmodev ~/tools/schema-visualizer

ER/Schema Visualizer

Data & DevOps

Paste CREATE TABLE DDL and get an ER diagram as SVG: tables with typed columns, primary keys, and foreign-key arrows in a deterministic layered layout. Pan and zoom the live diagram; export the SVG.

What it does

Parses CREATE TABLE statements (a tolerant common subset of Postgres, MySQL, and SQLite) into tables, typed columns, and foreign keys, then draws an ER diagram as SVG: one box per table with a title bar and one row per column (name TYPE, primary keys highlighted), plus orthogonal arrows from each referenced table down to the table that references it. The layout is deterministic — the same DDL always draws the same diagram, in every port. 100% client-side.

How to use it

  1. Paste DDL into CREATE TABLE DDL — a sample three-table schema is prefilled and its diagram is already drawn (it ships pre-rendered in the page itself).
  2. Referenced tables lay out above the tables that reference them; FK arrows are labeled with their column pair.
  3. Drag to pan; use − / + to zoom and Reset to fit.
  4. Statements that don’t parse (an CREATE INDEX, a broken table) appear as chips above the diagram — the rest still draws.
  5. Copy the SVG source or download it as schema.svg.

Examples

Two tables, one FK — the sample, abridged →

CREATE TABLE users (id INTEGER PRIMARY KEY, email VARCHAR(255) NOT NULL);
CREATE TABLE posts (id SERIAL PRIMARY KEY, user_id INTEGER NOT NULL REFERENCES users(id), title TEXT);

users draws above posts; an arrow runs from the bottom of users to the top of posts, labeled user_id → id.

Tolerant parsing —

  • CREATE TABLE IF NOT EXISTS, TEMP/UNLOGGED, dotted names (dbo.things) all parse.
  • Quoted identifiers keep their text: `order items` and "user id" draw literally.
  • Table-level PRIMARY KEY (a, b) and FOREIGN KEY (a, b) REFERENCES u (x, y) mark and pair composites.
  • DEFAULT …, ON DELETE CASCADE, COMMENT '…', CHECK (…), UNIQUE (…) are skipped silently; a REFERENCES with no target column resolves to the referenced table’s primary key.

Good to know

  • Private: parsing and drawing are local — nothing leaves the browser.
  • Multi-word types (TIMESTAMP WITH TIME ZONE, DOUBLE PRECISION) render whole; an unknown word after a type joins it (greedy rule, no type dictionary).
  • The same logic ships as a Go CLI twin (cosmodev foundation) held to the same test vectors — the SVG output is byte-identical across implementations.
  • Related tools: SQL Playground, CSV to SQL Importer, JSON to SQL INSERT.
Source code14 languages

100% client-side · your data never leaves your browser. Found this useful? Share it with a teammate.