draft

Read a SQL schema as a diagram

Paste a CREATE TABLE script — a migration, a pg_dump, a file from a codebase you did not write — and get an entity-relationship diagram you can pan, zoom and edit. It runs entirely in your browser. Nothing is uploaded.

Open the app

customers id bigserial PK email varchar(255) UQ display_name text created_at timestamptz addresses id bigserial PK customer_id bigint FK line1 text line2 text city text postcode varchar(16) country char(2) categories id bigserial PK parent_id bigint FK slug varchar(64) UQ title text products id bigserial PK category_id bigint FK sku varchar(32) UQ title text price_cents integer active boolean inventory product_id bigint PK on_hand integer reserved integer orders id bigserial PK customer_id bigint FK address_id bigint FK status varchar(24) placed_at timestamptz total_cents integer order_lines id bigserial PK order_id bigint FK product_id bigint FK quantity integer unit_cents integer payments id bigserial PK order_id bigint FK provider varchar(32) reference text amount_cents integer captured_at timestamptz reviews id bigserial PK product_id bigint FK customer_id bigint FK rating smallint body text
9 tables and 11 relations, laid out automatically. This picture was produced by the command line tool on this page's build, from the same code the app runs.

The SQL is the document

Most diagram tools import your schema into a model of their own, and from then on you have two copies that drift. draft keeps one. The diagram is a projection of the text, and editing the diagram rewrites the exact bytes of your script.

Rename a table on the canvas and every REFERENCES and key clause that mentions it is updated in place. Your comments, your blank lines, your vendor-specific clauses the parser never even understood — all still there, byte for byte, because nothing outside the span being changed is ever touched.

What it does

Nothing is uploaded

There is no server to upload to. The parser, the layout engine and the renderer are compiled to WebAssembly and run in your tab. Even a share link is not hosted: the project is compressed into the URL fragment, and browsers never transmit a fragment. A test in this repository drives the real application in a real browser and fails if anything leaves the origin that you did not ask for — the one thing you can ask for is a #u= link to a schema on another server. The details are here.

Your dialect

Also a command line tool

The same parser, layout engine and renderer build as a native binary with no window at all — useful in a build, a pre-commit hook, or a pull request comment.

$ draft render schema.sql -o schema.svg
$ draft render schema.sql --png -o schema.png
$ draft render schema.sql --json | jq '.relations | length'

And as a desktop application for macOS, Linux and Windows.