Tools / Database Schema Designer
What is inside
A line with no colon starts a table. Fields are name:type with optional words: required, unique, index, default=VALUE and an arrow ->table for a foreign key. Comments start with #.
PostgreSQL, MySQL and SQLite. Types, auto-increment, UUID defaults, booleans, timestamps and identifier quoting change with the dialect. Reserved words such as order and user are quoted for you, with a warning.
A field named customer_id points at the customer table when it exists. An arrow, ->customer or ->customer.code, sets it directly. The column takes the type of the key it points at. A foreign key to a column that is not unique is flagged.
Tables are written so that referenced tables come first. If two tables refer to each other, the loop is reported and the foreign key is added with ALTER TABLE afterwards (SQLite accepts it inside CREATE TABLE).
An id primary key on every table: auto-increment integer or UUID. Optional created_at and updated_at, optional index on foreign key columns, and a delete rule: cascade, set null or restrict.
Boxes for tables, a line for each foreign key, drawn as SVG you can download. Self-references and loops are drawn.
A Markdown document with every column, type, rules, default and reference, plus which tables point at each table.
Unknown types, unreadable lines, duplicate tables or fields, bad defaults, references to tables that do not exist, and similar problems are listed with the line number. Nothing is silently dropped.
Worked example
Click Sample. It describes a small shop with four tables: customer, product, order and order_line.
| Setting | Result |
|---|---|
| PostgreSQL, integer ids | Ids are INTEGER GENERATED ALWAYS AS IDENTITY, TIMESTAMPTZ for timestamps, and "order" is quoted because it is a reserved word. |
| MySQL | Ids are INT AUTO_INCREMENT, timestamps are DATETIME, `order` is quoted with backticks, and no extra foreign key indexes are written because InnoDB indexes them. |
| SQLite | Ids are INTEGER PRIMARY KEY AUTOINCREMENT. The output ran in SQLite with foreign keys switched on, and an order for a customer that does not exist was refused. |
| UUID ids | Ids become UUID with gen_random_uuid() in PostgreSQL, CHAR(36) with UUID() in MySQL, and plain TEXT in SQLite, which has no default. Foreign key columns follow. |
| Delete rule: cascade | Every foreign key gets ON DELETE CASCADE. Set null on a required column triggers a warning. |
Reading the result
Tables, columns and foreign keys it found. If a foreign key you expected is missing, the name did not match a table or the arrow was misspelled. See the list under it.
Each says which line and what it did instead, for example "unknown type, used text". When any part differs from what you wrote, a yellow box under the SQL lists each one and says to resolve them before you run it, and the SQL starts with a comment saying so.
A line runs from the foreign key column to the id it points at. The filled dot is at the table being pointed at.
Use it as documentation. Required, unique and indexed show in the Rules column.
How to use it
Step 1
Type or paste your tables, or click Sample and edit it.
Step 2
Pick the dialect and the primary key style.
Step 3
Read the warnings. Fix the lines they name.
Step 4
Check the SQL tab and the diagram. Switch dialects to compare.
Step 5
Copy or download the SQL, the SVG or the Markdown. Test the SQL on your database version before using real data.
Common mistakes
The database rejects it. The tool does not write that foreign key. It tells you and leaves the column plain until you mark the target column unique.
Deleting the parent would have to write null into a column that cannot be null. The tool writes that foreign key without a delete rule and says so.
MySQL needs a length to index TEXT and JSON. The rule is left out with a note. Use string(n).
default=abc on an int, or a number on a bool. They are skipped with a warning instead of producing SQL that fails.
Index names are unique across a schema, and a_b with column c and a with column b_c both want idx_a_b_c. The tool numbers the second.
order, user, group and key need quoting. The tool quotes them and warns.
PostgreSQL allows 63 characters in an identifier and MySQL 64. The tool refuses to produce SQL, lists the names, and the Copy and Download buttons stay off until you shorten them.
Design notes
The PostgreSQL manual says declaring a foreign key does not automatically create an index on the referencing columns, and that it is often a good idea to index them. That is why the tool has an option to index foreign key columns, on by default. MySQL InnoDB is handled differently, so it writes none.
The PostgreSQL manual says a foreign key must reference a primary key or a unique constraint. The tool warns when ->table.column points at a column that is not marked unique.
The PostgreSQL manual describes GENERATED ... AS IDENTITY columns. The tool uses GENERATED ALWAYS AS IDENTITY for PostgreSQL integer ids.
What it cannot do
Every table gets a single id primary key. There are no composite primary keys, composite unique constraints or composite foreign keys.
Write the join table yourself, like order_line in the sample.
Add them to the SQL by hand.
updated_at gets a default only. Refreshing it on update needs a trigger, which the tool does not write.
It writes CREATE statements for a new schema. It does not read an existing database or write ALTER scripts to change one.
The output for the sample and the edge cases was run on MySQL 8.4.3, SQLite and PostgreSQL (PGlite 0.6.1, PostgreSQL compiled to WebAssembly). Your version may differ. For example gen_random_uuid() needs PostgreSQL 13 or the pgcrypto extension, and DEFAULT (UUID()) needs MySQL 8.0.13 or later.
What it does
Free database schema designer: describe tables in plain text, get PostgreSQL, MySQL or SQLite CREATE TABLE SQL, foreign keys, indexes, an ER diagram and a data dictionary. It runs in your browser.
| Function | What it does |
|---|---|
| Input | Short line syntax, with a type list that maps to each SQL dialect |
| Choose SQL dialect and primary key style | Yes, PostgreSQL, MySQL, SQLite, integer or UUID |
Questions
No. Parsing, generating and drawing run in your browser tab.
The field name must be the table name plus _id, such as customer_id, or use ->customer. The table must exist in your text.
It is a reserved word in at least one dialect, such as order, user or group. Quoting keeps the SQL valid. A different name avoids the problem.
Every table already has an id primary key, so the extra one is skipped with a warning.
Read it first and try it on a test database of your version.
Nothing. No account.
Your data
The tool runs in this browser tab and does not need a server. Your table descriptions stay in the page. The .sql file, the SVG diagram and the Markdown dictionary are made on your device only when you press their buttons. Nothing is uploaded or shared.
Keep going
Sources

Database Schema Designer runs in your browser. No account needed.
Database Schema Designer
Free database schema designer: describe tables in plain text, get PostgreSQL, MySQL or SQLite CREATE TABLE SQL, foreign keys, indexes, an ER diagram and a data



