CSV to INSERT statements with CREATE TABLE for four databases
JSON to SQL
Seed a table from an API response or fixture file in the time it takes to paste it.
Loading tool…
How to use json to sql
Paste a JSON array of objects or open a .json file.
Set the table name and choose your database.
Pick rows per INSERT and whether to add CREATE TABLE and a transaction.
Copy or download the SQL.
What this tool does
- Columns are the union of every object's keys, in the order they first appear; missing keys become NULL.
- Nested objects and arrays are stored as JSON text, typed JSONB in PostgreSQL and JSON in MySQL.
- true and false become TRUE and FALSE, or 1 and 0 where the database has no boolean.
- Also accepts a single object, or {"rows": [...]} style wrappers with one array inside.
How the result is verified
The SQL is tokenised again and every literal is decoded and compared with your JSON values, row by row.
Frequently asked questions
What happens to null values?
They become NULL, and the column is created without NOT NULL.
Can I insert into a table that already exists?
Yes. Turn off 'Add CREATE TABLE' and set the table name to match; the INSERTs list column names, so the order in the table does not matter.
Is my data uploaded to a server?
No. Everything you drop, paste or type is processed by code running in this browser tab. You can check it yourself: open your browser's developer tools, watch the Network panel, and use the tool. No request carries your data.
Related tools
Batched INSERT statements from pasted CSV or JSON
Beautify or minify JSON with your choice of indentation
Flatten JSON arrays into spreadsheet rows with dot path columns
Readable SQL with clauses, joins and subqueries laid out