Spreadsheet to SQL Database Schema and ER Diagram
Add one file per table, let the tool infer types, keys and relationships, adjust them, then copy SQL for your database or download an ER diagram.
Runs in your browser. Your files never leave your device. See how to check
…
How to do it
- 1Add files
One CSV, XLSX or JSON file per table.
- 2Pick the dialect
Choose PostgreSQL, MySQL, SQLite or SQL Server.
- 3Review columns
Adjust types, keys and nullability.
- 4Set inserts
Choose how many rows to include as INSERTs.
- 5Export
Download the .sql file, copy it, or save the ER diagram.
About this tool
Moving data from spreadsheets into a database is a routine job that still takes too long: for every column you decide a type, whether it can be empty and how long text can be; you pick a primary key, work out which columns point to other tables, and write the CREATE TABLE statements by hand, then the INSERTs. This tool does the first draft for you. Add one CSV, TSV, JSON or XLSX file per table. For each column it scans every value and infers whether it holds integers, decimals, dates, date-times, booleans or text, how long the longest value is, whether any values are missing and whether all values are unique. A unique column named id, something_id or code becomes the suggested primary key. A column named like another table's key, such as customer_id in an orders table, becomes a foreign key when every value exists in that other table. You can override any type, key or nullability. The output is ready-to-run SQL for PostgreSQL, MySQL or MariaDB, SQLite or SQL Server, with identifiers quoted correctly for each, tables ordered so referenced tables come first, and optional INSERT statements with properly escaped values. An entity-relationship diagram shows tables, keys and links, and can be downloaded as SVG or copied as Mermaid code for documentation.
Who it is for
Developers bootstrapping a database, analysts loading data into a warehouse, students learning relational design and anyone migrating from spreadsheets to a real database.
Type mapping
| Detected | PostgreSQL | MySQL | SQLite | SQL Server | |---|---|---|---|---| | Integer | INTEGER / BIGINT | INTEGER / BIGINT | INTEGER | INTEGER / BIGINT | | Decimal | NUMERIC(18,4) | NUMERIC(18,4) | REAL | DECIMAL(18,4) | | Date | DATE | DATE | TEXT | DATE | | Date-time | TIMESTAMP | DATETIME | TEXT | DATETIME2 | | Boolean | BOOLEAN | BOOLEAN | INTEGER | BIT | | Text | VARCHAR(n) / TEXT | VARCHAR(n) / TEXT | TEXT | NVARCHAR(n) / NVARCHAR(MAX) |
Text lengths are rounded up with 25% headroom.
How keys are found
- Primary key: a column with no blanks and no repeated values, preferring names like id, *_id or code. - Foreign key: a column whose name matches another table's key (for example customer_id or customer for table customers) and whose values all appear in that key.
Before you run the SQL
Check money columns (DECIMAL is safer than REAL), time zones for timestamps, columns that should be unique, and indexes for columns you will search. Inferred types reflect the sample you loaded; future data may need wider columns.
Worked example
customers.csv and orders.csv become two tables: customers(customer_id INTEGER PK, name, email nullable, country, joined DATE) and orders(order_id VARCHAR PK, customer_id INTEGER FK → customers, ordered_at TIMESTAMP, total NUMERIC, paid BOOLEAN), with five INSERT rows each.
Not a migration tool
The output is a starting point, not a finished design. It does not create indexes, constraints such as CHECK or UNIQUE beyond the primary key, or triggers, and it does not normalise repeated groups into separate tables. Review the schema with the people who will query the data.
Privacy
Files are read in your browser and never uploaded.
Worked example
customers + orders CSV → PostgreSQL DDL with PK customer_id and FK orders.customer_id.
Quick facts
- Category: Developer & Data
- Works in your browser, no sign-up, no upload.
- Your input stays on your device.
- Available in English.
- Content last reviewed:
- Official source: SQL data types as implemented by PostgreSQL, MySQL, SQLite and SQL Server
Frequently asked questions
How do I create a SQL table from a CSV?
Add the CSV here, check the inferred types and copy the CREATE TABLE statement.
Which databases are supported?
PostgreSQL, MySQL/MariaDB, SQLite and SQL Server.
Does it detect foreign keys?
Yes, when column names and values match another table's key.
Can it generate INSERT statements?
Yes, up to 5,000 rows per table.
Can I export an ER diagram?
Yes, as SVG or Mermaid code.
Is my data uploaded?
No, everything runs in the browser.
