JSON to SQL Converter
Paste an API response or a JSON export. Get a table definition with inferred types and INSERT statements, with nested objects flattened into columns.
CREATE TABLE records ( id INTEGER NOT NULL, name VARCHAR(32) NOT NULL, email VARCHAR(32), active BOOLEAN NOT NULL, created TIMESTAMP NOT NULL, address_city VARCHAR(16) NOT NULL, address_country VARCHAR(16) NOT NULL, tags JSONB NOT NULL ); INSERT INTO records (id, name, email, active, created, address_city, address_country, tags) VALUES (101, 'Ada Lovelace', 'ada@example.com', TRUE, '2026-03-01T09:30:00Z', 'London', 'GB', '["admin","beta"]'), (102, 'Alan Turing', 'alan@example.com', FALSE, '2026-03-04T15:02:11Z', 'Wilmslow', 'GB', NULL), (103, 'Katherine Johnson', NULL, TRUE, '2026-03-09T08:00:00Z', 'Hampton', 'US', '[]');
Detected columns
Types are inferred from every value in the column. Override any that are wrong: zip codes and phone numbers with leading zeros stay text on purpose.
| Column | Type | Nullable | Longest value |
|---|---|---|---|
id | no | 3 | |
name | no | 17 | |
email | yes | 16 | |
active | no | 5 | |
created | no | 20 | |
address_city | no | 8 | |
address_country | no | 2 | |
tags | no | 0 |
How the conversion works
Every object becomes a row and every distinct key becomes a column, in the order keys first appear. One level of nesting is flattened with an underscore, which covers the common address.city style. Arrays such as tags are kept as JSON in a JSONB/JSON column so no data is lost. If they are really a list of related records, they belong in a separate table with a foreign key back to this one; sketch that in the ER diagram generator.
ISO 8601 strings like 2026-03-01T09:30:00Z are detected as timestamps. PostgreSQL and MySQL both accept that literal format; if you need time zones preserved in PostgreSQL, change the column to TIMESTAMPTZ after generating.
Questions
What JSON shape does it accept?
An array of objects, like an API response: [{"id": 1, "name": "Ada"}, …]. If you paste an object that contains an array (for example {"data": [ … ]}), the first array is used. Keys missing from some objects become NULL.
What happens to nested objects and arrays?
Nested objects are flattened one level: {"address": {"city": "Oslo"}} becomes an address_city column. Arrays and deeper structures are stored as JSON text in a JSONB (PostgreSQL), JSON (MySQL) or text column.
Can I query JSON directly instead?
Yes, most databases can: PostgreSQL has jsonb_to_recordset and ->> operators, MySQL has JSON_TABLE, SQL Server has OPENJSON, and SQLite has json_each. Converting to real columns is still better when you will filter, join or index on the fields.
Is the data sent anywhere?
No. Parsing and conversion run in your browser.
Related tools
- CSV to SQLCREATE TABLE with inferred types plus batched INSERT statements.
- SQL Data TypesThe same type across MySQL, PostgreSQL, SQL Server, Oracle and SQLite.
- SQL FormatterBeautify SQL in 12 dialects with keyword case, indent and comma style options.
- ER Diagram GeneratorPaste CREATE TABLE statements or DBML and get a draggable crow’s-foot diagram.