JSON to SQL Converter
Turn a JSON array into SQL: nested objects are flattened into columns, a CREATE TABLE is inferred from the values, and batched INSERT statements are written for your database.
JSON to SQL Converter
Runs in your browser — nothing you enter is uploaded or stored.
Scratchpad auto-saved
How it works — in four simple steps
No signup and nothing to install — it all runs in your browser.
Add your JSON
Paste it into the left box, press Open file, or drag a .json file onto it. Sample loads a realistic example.
Set the options
Adjust the options above the boxes — the output updates instantly as you change them.
Check the result
Read the status line: it reports rows, keys and any value that couldn't be represented in SQL.
Copy or download
Copy the SQL or download it as a .sql file. Nothing was uploaded at any point.
A key missing from some objects just becomes NULL in those rows — no need to normalise the JSON first.
Features
Nested data flattened
Nested objects become dotted columns (address.city), and arrays of plain values are joined so every row fits the grid.
Five SQL dialects
PostgreSQL, MySQL, SQLite, SQL Server and Oracle — with the right identifier quoting, boolean literals and column types for each.
Batched INSERTs
Rows are grouped into multi-row INSERT statements (capped at 1,000 for SQL Server) so large imports run fast.
CREATE TABLE included
Column types (INTEGER, DOUBLE, BOOLEAN, DATE, VARCHAR(n)…) are inferred from the actual values.
Private by design
Parsing and conversion run in your browser with JavaScript — your data is never uploaded, logged or stored.
About the JSON to SQL Converter
Seeding a database from fixture files, migrating API data or loading a NoSQL export into a relational table all start with JSON. This converter takes the array in your JSON (or the first array of objects inside it), flattens each object into columns — address.city becomes a column named address.city — and writes a CREATE TABLE plus INSERT statements.
Because JSON already has types, column inference is precise: JSON numbers become INTEGER/BIGINT or a floating type, JSON booleans become BOOLEAN (or the dialect's 0/1 type), and strings become DATE or TIMESTAMP when every value is an ISO date or date-time, VARCHAR(n) or TEXT otherwise. Keys missing from some objects simply produce NULL in those rows. Arrays of plain values are joined into text (a; b) and arrays of objects are stored as JSON text, which you can load into a JSON/JSONB column if your database has one.
Dialect handling matches CSV to SQL: correct identifier quoting, string escaping by doubling single quotes, N'' strings for SQL Server, INSERT ALL for Oracle, and a DROP TABLE line if you want the script to be re-runnable.
Examples
A small orders export from an API with a nested shipping object, ISO timestamps and a missing key.
[
{ "id": 5001, "customer": "Ada", "total": 37.5, "paid": true, "placed_at": "2026-10-20T14:05:00Z", "shipping": { "city": "London", "method": "standard" } },
{ "id": 5002, "customer": "Alan", "total": 19, "paid": false, "placed_at": "2026-10-21T08:12:00Z", "shipping": { "city": "Manchester" } }
]CREATE TABLE `orders` (
`id` INTEGER,
`customer` VARCHAR(50),
`total` DOUBLE,
`paid` TINYINT(1),
`placed_at` DATETIME,
`shipping.city` VARCHAR(50),
`shipping.method` VARCHAR(50)
);
INSERT INTO `orders` (`id`, `customer`, `total`, `paid`, `placed_at`, `shipping.city`, `shipping.method`) VALUES
(5001, 'Ada', 37.5, 1, '2026-10-20 14:05:00', 'London', 'standard'),
(5002, 'Alan', 19, 0, '2026-10-21 08:12:00', 'Manchester', NULL);This output was produced by the converter on this page with table orders and the MySQL dialect — load it with the “Orders” preset above and change any option to see the effect.
How JSON maps to SQL
| In JSON | Becomes in SQL |
|---|---|
| Array of objects | one row per object |
{"address": {"city": …}} | column "address.city" |
| JSON integer / float | INTEGER / floating type |
true | TRUE or 1 by dialect |
"2026-10-21T09:30:00Z" (all rows) | TIMESTAMP · DATETIME · DATETIME2 |
["a","b"] | 'a; b' |
Missing key / null | NULL |
Things that trip people up
- Dotted column names. Columns like address.city are valid when quoted, but awkward to query. Rename them (address_city) in the CREATE TABLE before running, and in the INSERT column lists.
- Nested arrays of objects. A relational table can't hold a list of child records; it's stored as JSON text. For a proper model, convert the child array to its own table.
- Huge integers. IDs larger than 2⁵³ lose precision when JSON is parsed in JavaScript. Quote them as strings in the JSON.
- Time zones. PostgreSQL gets the ISO value as written, but a TIMESTAMP (without time zone) column ignores the offset — use TIMESTAMPTZ if it matters. For MySQL, SQL Server and Oracle the T and a trailing Z are removed, so UTC times are stored as UTC wall-clock values.
JSON vs SQL at a glance
| Property | JSON | SQL |
|---|---|---|
| Specification | RFC 8259 (2017) · ECMA-404 | ISO/IEC 9075 + vendor dialects |
| File extension | .json | .sql |
| Media type | application/json | application/sql (RFC 6922) |
| Data types | string, number, boolean, null, object, array | per column: INTEGER, DOUBLE, BOOLEAN, DATE, VARCHAR … |
| Comments | No | Yes -- and /* */ |
| Nesting | Unlimited | None (tables) |
- JSON: Numbers are parsed as IEEE-754 doubles in JavaScript, so integers above 9,007,199,254,740,991 (2⁵³ − 1) lose precision.
- SQL: Identifier quoting differs by database: "double quotes" in PostgreSQL, SQLite and Oracle, `backticks` in MySQL, [brackets] in SQL Server.