Skip to content
migration.tools
JSON to SQL

JSON to SQL converter

Turn a JSON array into a CREATE TABLE statement and INSERTs. Nested objects are flattened into columns and types are inferred for the database you pick.

Going the other way? SQL to JSON

Options

JSON

SQL

The result appears here as soon as there is input.

Processed on this device. Nothing you paste or drop is uploaded.

How to use it

  1. 1Paste your JSON or drop a file onto the input panel.
  2. 2Adjust the options — the result updates as you type.
  3. 3Copy the SQL or download it. Drop several files to convert a batch into one ZIP.

How JSON becomes SQL

A table needs rows, so the converter first finds the list of records in your JSON — the top-level array, or the largest array of objects nested inside it — and makes one row per record.

Nested objects are flattened into dotted column names (address.city), arrays inside a record are written as JSON text in a single cell, and the header is the union of every key that appears in any record, so sparse data lines up correctly.

JSON and SQL, briefly

JSON is the default language of web APIs and document databases. It nests objects and arrays to any depth and distinguishes strings, numbers, booleans and null, but has no comments and no date type.

SQL INSERT scripts are the most portable way to load rows into a relational database: any client can run them, and they can be reviewed and version-controlled like code.

Questions

What if my JSON isn't an array of objects?

The converter looks for the list of records inside the document — for example the array under "data" or "items" in an API response — and tells you which one it used. A single object becomes one row.

How are column types chosen?

Each column is scanned: whole numbers become INTEGER or BIGINT, decimals a floating-point type, true/false a boolean, ISO dates DATE or TIMESTAMP, and everything else VARCHAR or TEXT sized to the longest value. Columns with no empty values are marked NOT NULL. Quotes in text are escaped for the dialect you choose.