SQL to ER Diagram Generator
Paste your CREATE TABLE statements and get an entity relationship diagram instantly: tables, columns, primary keys and foreign key relationships are detected automatically. Works with PostgreSQL, MySQL and SQL Server DDL, exports the diagram as SVG and as Mermaid erDiagram code. Everything runs in your browser — your schema is never uploaded.
Do more than sql to er diagram generator — meet Chat2DB
Chat2DB is an AI-powered SQL client for Windows, macOS and Linux. Write SQL in natural language, format and optimize queries automatically, and manage MySQL, PostgreSQL, Oracle and 20+ other databases in one workspace.
How to use
- Paste one or more CREATE TABLE statements, including FOREIGN KEY or inline REFERENCES clauses.
- The ER diagram renders instantly; primary keys are marked with a key icon and foreign keys with an arrow.
- Download the diagram as SVG, or copy the generated Mermaid code into your docs, GitHub README or wiki.
Frequently asked questions
How do I create an ER diagram from SQL?
Export your schema as CREATE TABLE statements (for example with pg_dump --schema-only or mysqldump --no-data), paste the DDL into this tool, and it draws the entity relationship diagram automatically. Tables become entities, and every FOREIGN KEY or inline REFERENCES clause becomes a relationship line between the referencing column and the referenced table.
What SQL dialects does this ER diagram generator support?
The parser understands standard CREATE TABLE syntax from PostgreSQL, MySQL, MariaDB, SQL Server and SQLite: quoted or backticked identifiers, schema-qualified names, inline column constraints, and table-level PRIMARY KEY and FOREIGN KEY clauses. Dialect-specific storage options such as ENGINE=InnoDB are simply ignored, so a mixed dump usually renders fine.
Can I get the diagram from a live database instead of DDL?
This tool works from DDL text only, which keeps everything in your browser. If you want ER diagrams generated directly from a live connection, Chat2DB is a free AI database client that visualizes tables and relationships for PostgreSQL, MySQL, SQL Server and 20+ other engines — download it at https://chat2db.ai/download or use the web version at https://app.chat2db.ai.
