Raw capture โ raw/sqltoerdiagram.md
url: https://github.com/royalbhati/sqltoerdiagram date_fetched: 2026-07-05 backfilled: true
A free, open-source online ERD generator. Paste a SQL schema (CREATE TABLE
statements) โ get a clean, interactive entity-relationship diagram.
100% local ยท no signup ยท no upload. It runs entirely in your browser, so your schema never leaves your machine โ no server, no backend. Live at sqltoerdiagram.com.
Every other SQL-diagram tool is either paywalled, ugly, or slow. SQL to ER Diagram is a single static page that stays smooth at hundreds of tables, edits your SQL two-way, and shares a whole diagram in a single link โ with no account and nothing leaving your browser.
Standard CREATE TABLE/ALTER TABLEDDL acrossPostgreSQL, MySQL, SQLite, SQL Server & Snowflake.
Canvas rendererwith cached bitmaps + viewport culling โ smooth at hundreds of tables (benchmarked- ~120fpswhile zooming 300 tables / 593 FKs).
Dragtables,- scroll / pinch to zoom, and pan.
Hub-aware layered auto-arrange: the most-connected table is placed on one side with its related tables aligned beside it.- Horizontal / Verticaldirection and- Compact / Comfortable / Spaciousspacing live under the- Arrange โพmenu.
Your arrangement is saved: positions and the camera persist automatically, so reloading restores your exact layout. Editing SQL keeps your manual positions โ only brand-new tables get auto-placed beside the rest.- Arrangere-runs layout on demand.
Double-clicka table name, column name, or column type to edit it inline. The change is applied as a- surgical text edit(comments, formatting, and unsupported clauses are preserved), and a table rename updates every- REFERENCESto it.
Add columns: pin a table, then- + add column. The new column is inserted into your SQL with a default type for the selected- dialect(PostgreSQL / MySQL / SQLite / SQL Server / Snowflake) and opens inline so you can name it. Editing a column type shows dialect-aware suggestions.
A bottom-left palette adds sticky notesandgroup boxesto label and cluster sections. Drag to move, drag the corner to resize, double-click to edit text, click to select (colour swatches + delete), or press Delete. They're part of the diagram โ included in saves, share links, and PNG/SVG exports.
Save / Open projects:- Savedownloads a- .jsonproject (SQL + layout + camera- dialect); Openloads one back.
dialect);
#โฆfragment is never sent to a server, so sharing needs- no backend, and opening the link restores the exact diagram.Exportto- PNG(raster) and- SVG(vector).
Syntax-highlighted SQL editor: keywords / types / strings / comments / numbers are colored via a paint layer behind the textarea. Re-tokenizing is a single linear pass coalesced to one animation frame, so typing stays instant (~6ms full repaint on a 45KB / 300-table script, sub-ms on normal schemas).
npm install
npm run dev # http://localhost:5173
npm run build # outputs static files to dist/
npm run preview # preview the production build locally
dist/ is plain static HTML/JS/CSS โ drop it on any static host:
dist/to a- gh-pagesbranch, or use an action.npm run build, publish dir- dist.Any web server / S3 bucketโ just upload the contents of- dist/.
CREATE [OR REPLACE] [TEMPORARY | TRANSIENT] TABLE [IF NOT EXISTS] name ( ... )with quoted / backtick /- [bracket]/- schema.qualifiednames.
PRIMARY KEY,NOT NULL,UNIQUE,REFERENCES other(col).PRIMARY KEY (...),UNIQUE (...),FOREIGN KEY (...) REFERENCES other(...),CONSTRAINT ... FOREIGN KEY ....ALTER TABLE x ADD [CONSTRAINT ...] FOREIGN KEY (...) REFERENCES y(...).--,#) and block (/* */) comments are ignored.Select BigQuery from the dialect dropdown to work with BigQuery SQL instead of DDL.
WITH โฆ AS (โฆ)query โ noCREATE TABLEstatements needed. Each CTE becomes a table node in the diagram.SELECTlist of each CTE (using aliases where present).FROMandJOINreferences: a CTE that reads from another CTE gets an edge between them, and references to base tables create stub nodes connected to the CTE.Backtick-quoted three-part names (project.dataset.table) are supported โ the table portion is used as the node label.
Viteโ build + dev server.
| Key | Action |
|---|---|
| โ / Ctrl + Enter | Re-arrange |
| Double-clickcanvas | Zoom in |
| Drag the pane divider | Resize the editor |
MIT ยฉ Royal Bhati. Fork it, self-host it, add your own SQL dialects โ go for it.