JSON to SQL Schema Generator
Paste JSON to generate a CREATE TABLE statement. The tool reads an object or an array of objects, infers a column type for each key from the values across every row, and writes DDL for Postgres, MySQL or SQLite. An id column is marked as the primary key.
How to generate a SQL schema from JSON
- Paste your JSON. An array of objects gives the most accurate column types.
- Set the table name and choose Postgres, MySQL or SQLite.
- Copy the CREATE TABLE statement or download it as a .sql file.
Examples
Array of objects to Postgres DDL
[{"id":1,"name":"Ada","active":true,"score":9.5}]CREATE TABLE my_table ( id INTEGER PRIMARY KEY, name VARCHAR(255), active BOOLEAN, score DOUBLE PRECISION );
Frequently asked questions
Is my data uploaded anywhere?
No. The schema is generated entirely in your browser, so your JSON and the CREATE TABLE output never leave your device. Nothing is uploaded, logged or stored on a server.
How are column types inferred?
Each key is checked across every row. Whole numbers become an integer type, numbers with decimals become a float type, true or false becomes a boolean, and text becomes VARCHAR(255) or TEXT depending on the dialect. A column that mixes types, or holds only null, falls back to TEXT so nothing is lost.
Which dialects are supported?
Postgres, MySQL and SQLite. The structure stays the same and only the type names change: for example an integer is INTEGER in Postgres and SQLite but INT in MySQL, and a float is DOUBLE PRECISION, DOUBLE or REAL respectively. SQLite has no boolean or varchar types, so those map to INTEGER and TEXT.
How is the primary key chosen?
If a column named id exists (case-insensitive), it is marked PRIMARY KEY. Only one primary key is added. If there is no id column, no primary key is emitted and you can add one yourself.
What if my objects have different keys?
The schema uses the union of all keys as the column list, in the order each key first appears. A type is still inferred for every column from whichever rows contain it, so partial or heterogeneous records are handled.
Are table and column names made safe?
Yes. Identifiers are reduced to letters, digits and underscores, and a leading digit is prefixed with an underscore so the name stays valid. This is a generator for trusted data, so review the DDL and adjust types, lengths or constraints before running it.
Related tools
JSON to SQL
Convert JSON to SQL INSERT statements online. Paste an array of objects, set a table name, and get ready-to-run INSERTs. Runs in your browser.
SQL Formatter
Format and beautify SQL online. Put clauses on their own lines, indent the column list and uppercase keywords. Fast and runs in your browser.
JSON Formatter
Format, validate and minify JSON online. Pretty-print with custom indentation, sort keys and catch syntax errors. Runs in your browser.
.env to JSON
Convert a .env file to JSON, or JSON back to .env. Parses KEY=value lines, comments, quotes and export. Runs entirely in your browser.
Aspect Ratio Calculator
Calculate aspect ratios fast. Enter a ratio like 16:9 and one dimension to get the other, or enter width and height to simplify the ratio.
Base58 Encoder
Encode and decode Base58 online with the Bitcoin alphabet. Convert text to Base58 or back, UTF-8 safe, no confusing 0 O I l. Runs in your browser.