How to use the JSON to SQL
- Paste a JSON array of objects or open a
.jsonfile. - Choose whether nested objects are flattened into columns (
dimensions_width) or stored as one JSON column. - Select the SQL dialect, table name and the statements to include.
- Copy the SQL or download it as a
.sqlfile.
What does JSON to SQL conversion do?
It maps a JSON array onto a relational table: every object becomes a row, every key a column. The converter scans all objects to collect the full set of columns (objects with missing keys get NULL), infers a SQL type for each column, and writes CREATE TABLE plus batched INSERT statements.
[{ "id": 1, "sku": "KB-001", "price": 89.99, "in_stock": true }]
becomes, for PostgreSQL:
CREATE TABLE "products" (
"id" INTEGER,
"sku" VARCHAR(16),
"price" NUMERIC(10,2),
"in_stock" BOOLEAN
);
INSERT INTO "products" ("id", "sku", "price", "in_stock") VALUES (1, 'KB-001', 89.99, TRUE);
Handling nested objects
| Option | Result | Use when |
|---|---|---|
| Flatten to columns | dimensions.width → column dimensions_width | You want to filter and index the nested fields |
| Keep as JSON value | One dimensions column of type JSON / JSONB | The structure varies or you query it with JSON functions |
Arrays are always stored as JSON text. In PostgreSQL the JSON column type is JSONB, in MySQL JSON; SQLite, SQL Server and Oracle store it as text.
JSON types vs SQL types
- Numbers: integers become
INT(orBIGINTabove 2,147,483,647); decimals becomeDECIMALwith enough precision for the largest value. - Booleans:
TRUE/FALSEin MySQL and PostgreSQL,1/0in SQLite, SQL Server (BIT) and Oracle. - Strings that look like dates (
2026-02-14or ISO timestamps) becomeDATEorDATETIME/TIMESTAMPcolumns. - null always becomes
NULL.
Before you run it
Check the generated VARCHAR lengths and add indexes or foreign keys your schema needs — or design the table yourself with the CREATE TABLE generator and generate only the inserts. If the JSON fails to parse, the JSON Formatter shows exactly where. Spreadsheet data? Use CSV & Excel to SQL.
Tools that pair well with the JSON to SQL
- SQL to JSON, CSV & Excel — Paste a SQL dump or a few INSERT statements and get the rows back as JSON, CSV or an Excel workbook with one sheet per table.
- JSON to Excel — Turn a JSON array into a real Excel workbook.
- Excel to JSON — Open an .xlsx workbook or paste cells straight from Excel or Google Sheets and get clean JSON.
- CSV & Excel to HTML Table — Paste spreadsheet cells, CSV or JSON and get semantic, escaped HTML table markup — with an optional ready-made style and a live preview.
Frequently asked questions
What JSON shape does the converter need?
{"items": [...]}) is unwrapped automatically.