Free SQL→ER diagram tool, runs in the browser, nothing uploaded
Posted by robhati 3 days ago
Comments
Comment by written-beyond 3 days ago
Comment by CraigJPerry 3 days ago
Author is top notch in my book. I'm a sucker for someone taking a complex problem and distilling out a simple solution. I don't know of higher praise to give a developer.
Comment by ronbenton 3 days ago
const $ = (id) => document.getElementById(id);
Comment by lelanthran 3 days ago
Yeah, my first thought was that the diagramming bit needs to be ripped out into its own library, because I can see a use for the diagramming bits for more than ER diagrams.
Comment by Galanwe 3 days ago
Comment by sixtyj 3 days ago
Comment by elias1233 3 days ago
Comment by michaelmior 3 days ago
That's not to say that the tool is useless or that diagrams of this sort are unhelpful. I'll admit I'm being pedantic and others will probably disagree.
Comment by ezst 3 days ago
Isn't the fact that they are _mostly_ interchangeable the foundational principle of hundreds of ORMs? Of course the DDL doesn't say much about the entity's lifecycle, but if the bar is set at representing its relationships, fields and cardinality as a graph, it seems sufficient?
Comment by michaelmior 2 days ago
Comment by frollogaston 3 days ago
Comment by michaelmior 2 days ago
Comment by manoDev 3 days ago
I guess nowadays few people care about this difference.
Comment by marcosdumay 2 days ago
Comment by systems 3 days ago
so the db already exist, but they have no er, and maybe even little docs
so it act more like an exploratory tool, ideally, it should allow you to create views and add notes, so you dont have to look at the full er at once, especially if the number of table is huge, and if many of those tables are missing foreign keys
Comment by throwaway7783 2 days ago
Comment by Stitch4223 2 days ago
Many to many will lead to an extra table (which can have additional properties, requiring this table to be modelled as an entity), one to many leads to the inclusion of a foreign key to another unique key (referring all columns of that key, _id is an implementation decision, compound primary keys are possible). One to one can be implemented in multiple ways, like one to many with a uniqueness constraint by the referring table or even by merging entities to a single table.
The raw SQL can be revealing but when entities have merged into one table it’s harder to tell what is what, unless a certain set of columns appears over different tables.
Comment by michaelmior 2 days ago
Another is that in ER diagrams, relationships themselves can have attributes. Personally I think it tends to make more sense to convert relationships to entities in this case most of the time, but it can be useful.
Finally, relationships in ER diagrams can be N-ary and connect more than two entities while foreign keys in SQL always reference one other table. Of course you can have multiple foreign keys on a table to represent this, but not without some loss of semantics.
Comment by thunderbong 3 days ago
An example would be really helpful.
Comment by michaelmior 2 days ago
Comment by jitl 3 days ago
one man’s simplicity is another man’s headache
Comment by robhati 3 days ago
No backend, no accounts, no data leaving your machine.
A few implementation details that were fun:
* Built on <canvas> instead of DOM/SVG. Tables are rasterized into cached bitmaps with viewport culling, which keeps things smooth even with hundreds of tables on screen.
* The SQL parser tracks source spans for every token. That lets edits stay surgical so a rename a table and only the relevant identifier (and its references) change while comments and formatting remain untouched.
* The URL contains the entire schema. Sharing simply serializes the schema into the URL itself, so there's no backend, no stored state, and no account required.
* I also experimented with a Rust/WASM version because why not? but the parser was ~37% slower because the JS↔WASM boundary cost outweighed the compute savings but The O(n^2) overlap-resolution pass was about 2.2x faster though * In the end I stuck with plain JavaScript. No framework ~32KB gzipped
Comment by Hendrikto 3 days ago
Isn’t that going to be a problem due to the URL length limitations?
> It is RECOMMENDED that all senders and recipients support, at a minimum, URIs with lengths of 8000 octets in protocol elements.
Comment by johndough 3 days ago
Comment by flowerlad 2 days ago
Comment by __natty__ 3 days ago
Comment by vatsachak 2 days ago
Comment by corkybeta 3 days ago
Comment by robhati 3 days ago
Comment by ffsm8 3 days ago
Eg your example diagram has an optimal order in which there are no overlapping lines... But it's surprisingly hard to figure that out without doing n^m calculations... And I wanted to use it in a game, so a shitton of tiles.
Dunno where I was going with this, just got reminded of that project after looking at this great implementation.
It also reminded me of the xyflow lib
Comment by johndough 3 days ago
However, there are graphs that do not allow planar embeddings (e.g. K_5 or K_3,3, see https://en.wikipedia.org/wiki/Planar_graph).
In this case, you'll probably want to look into heuristics that produce a low number of crossings and little distortion when new vertices are added.
Comment by tharkun__ 3 days ago
Also, the `reviews` table overlaps the line from `order_items` to `products` and moving `order_items` down for example gets rid of that problem.
Not saying the project isn't cool, but this layout isn't optimal as per your constraints.
Comment by ffsm8 3 days ago
Comment by jeffreygoesto 3 days ago
Comment by throwatdem12311 3 days ago
For visualizing query plans. One of the most useful tools for optimizing sql queries I’ve ever used.
Just make sure to download the fully offline v2 version at the bottom if you want to use it with anything sensitive.
Comment by Igor_Wiwi 3 days ago
Comment by mingodad 3 days ago
Comment by Kuyawa 3 days ago
Comment by petilon 3 days ago
Comment by mulquin 2 days ago
Comment by eventinbox 2 days ago
Comment by hoofedear 3 days ago
Edit: should clarify mine is also free! It’s quite specific to my needs but I’m happy with it
Comment by WhyIsItAlwaysHN 3 days ago
Basically integrate sqlglot to translate the schema between dialects and then use a base dialect for generating the schema.
The two tools seem complementary and you seem to be a better designer, so it would be nice to see it all together
Comment by ktzar 3 days ago
Comment by Alifatisk 3 days ago
I loved MySQL Workbench, but it had its faults. Is there any equivalent alternative today? I've dreamed about an app that fuses MySQL Workbench + real-time collaboration, so I can share the same workspace with others in the team and see what others are are up to and collaborate on things.
Comment by estetlinus 3 days ago
Comment by graemep 3 days ago
This might be a good implementation but is it not easier to use something that can connect to your database than having to copy and paste chunks of SQL?
Comment by zikohh 2 days ago
Comment by CodesInChaos 3 days ago
For example in a multi-tenant application 90% of tables will link to the tenant table, but those links add little value to the viewer, so hiding these would be nice.
Comment by osrec 3 days ago
Comment by giovannibonetti 3 days ago
Comment by 1dontnkow_ 3 days ago
Comment by victor106 2 days ago
Comment by rognjen 3 days ago
Comment by wateralien 3 days ago
Comment by rognjen 1 day ago
There is even a big "Send a PR" button...
Comment by Footprint0521 2 days ago
Once that’s done I guess I can just clean room design it to wasm and post it on npm lol
Goals for someday
Comment by swatiahuja 3 days ago
Comment by _f1ou 3 days ago
Comment by serious_angel 3 days ago
Just to clarify, what link is it?
I've check it out, and the GitHub icon, in the header on the top right corner, is correct, and links to the following project:
- https://github.com/royalbhati/sqltoerdiagramComment by robhati 3 days ago
Comment by robhati 3 days ago
Comment by flojo 3 days ago
Comment by ahmdnassir1 3 days ago
Comment by mehtablr 3 days ago
Comment by thisislife2 3 days ago
Comment by clutter55561 3 days ago
Comment by henryecw 3 days ago
Comment by agentic_vector 3 days ago
Comment by John_Kwick 3 days ago
Comment by linzhangrun 3 days ago
Comment by akess 7 hours ago
Comment by robhati 3 days ago
So I ended up building my own.
You paste in your CREATE TABLE statements and it generates an interactive ER diagram right in the browser. You can drag tables around, auto arrange the layout, edit table/column names directly on the canvas (it rewrites the SQL for you), add notes and group boxes, and export as PNG or SVG.
No backend, no accounts, no data leaving your machine.
A few implementation details that were fun:
* Built on <canvas> instead of DOM/SVG. Tables are rasterized into cached bitmaps with viewport culling, which keeps things smooth even with hundreds of tables on screen.
* The SQL parser tracks source spans for every token. That lets edits stay surgical so a rename a table and only the relevant identifier (and its references) change while comments and formatting remain untouched.
* The URL contains the entire schema. Sharing simply serializes the schema into the URL itself, so there's no backend, no stored state, and no account required.
* I also experimented with a Rust/WASM version because why not? but the parser was ~37% slower because the JS↔WASM boundary cost outweighed the compute savings but The O(n^2) overlap-resolution pass was about 2.2x faster though * In the end I stuck with plain JavaScript. No framework ~32KB gzipped
It's a small too nothing great I just figured others might find it useful too.
Comment by dickiedyce 3 days ago
(Only minor tweak one could suggest would be multiple table selection for dragging... but to quote Frasier: "Think about it, Niles. What's the one thing better than an exquisite meal? An exquisite meal, with one tiny flaw we can pick at all night." Niles, raising a glass: "Ah, of course, to impossible standards.")
Comment by freeopinion 3 days ago
- Dragging a group should also drag the tables within the group.
- It would be nice to be able to drag relationship lines to reshape their curves around other tables.
But what is here now is so well crafted that it feels uncomfortable asking for features without acknowledging how impressive it already is.
Comment by devladpopov 2 days ago
Comment by hitoshi1964 3 days ago
Comment by throwaway613746 3 days ago