Skip to content
hateitall

JSON to SQL

Seed a table from an API response or fixture file in the time it takes to paste it.

Processed locallyIn: JSONOut: SQL

Loading tool…

How to use json to sql

  1. Paste a JSON array of objects or open a .json file.

  2. Set the table name and choose your database.

  3. Pick rows per INSERT and whether to add CREATE TABLE and a transaction.

  4. 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.

CSV to INSERT statements with CREATE TABLE for four databases

CSV · TSV→ SQLLight on device

Batched INSERT statements from pasted CSV or JSON

CSV · JSON→ SQLLight on device

Beautify or minify JSON with your choice of indentation

JSON→ JSONLight on device

Flatten JSON arrays into spreadsheet rows with dot path columns

JSON→ CSVLight on device

Readable SQL with clauses, joins and subqueries laid out

SQL→ SQLLight on device