What is a JSON to SQL converter?
Seeding a database from an API response, a fixtures file, or a NoSQL export usually means hand-writing INSERT statements. This tool generates them: paste a JSON array of objects and get a CREATE TABLE with types inferred from your data plus a single multi-row INSERT, ready for migrations, seed scripts, or a quick psql paste. Quoting and escaping follow the SQL standard so the output is portable.
Edge cases & gotchas
- SQL injection is a quoting problem: values are escaped by doubling single quotes, never interpolated raw, but always review generated SQL before running it against production.
- MySQL defaults to backtick identifiers; enable
ANSI_QUOTESor swap"for backticks if needed. - SQLite has no BOOLEAN storage class: TRUE/FALSE become 1/0 automatically.
NaN/Infinityare not valid JSON or SQL numbers; they become NULL.- Column set is the union of keys across all objects; a missing key inserts NULL.
- One multi-row INSERT is fast, but some databases cap parameters/row counts. Split very large arrays.
Type & value mapping reference
| JSON value | SQL output |
|---|---|
42 | 42 (column INTEGER) |
9.5 | 9.5 (column REAL) |
true | TRUE (column BOOLEAN) |
"it's" | 'it''s' (column TEXT) |
null / missing key | NULL |
{"k":1} / arrays | '{"k":1}' JSON text |
How to use
- Paste a JSON array of objects into the Input pane (or load a file / the sample).
- You get a
CREATE TABLEwith inferred column types plus one multi-rowINSERT. - Column types are inferred from the data: INTEGER, REAL, BOOLEAN, or TEXT.
- Strings are single-quoted with quotes doubled (
''); nested objects are stored as JSON text. - Copy the SQL into psql, the sqlite3 shell, MySQL, or a migration file.
Examples
Array of objects → CREATE TABLE + INSERT
[{ "id": 1, "name": "Ann" }, { "id": 2, "name": "Bob" }]CREATE TABLE "data" (
"id" INTEGER,
"name" TEXT
);
INSERT INTO "data" ("id", "name") VALUES
(1, 'Ann'),
(2, 'Bob');Quotes, nulls and booleans
[{ "note": "it's fine", "score": null, "active": true }]INSERT INTO "data" ("note", "score", "active") VALUES
('it''s fine', NULL, TRUE);Nested objects → JSON text column
[{ "id": 1, "meta": { "tags": ["a"] } }]INSERT INTO "data" ("id", "meta") VALUES
(1, '{"tags":["a"]}');FAQ
Which SQL dialect is generated?
Portable ANSI SQL: double-quoted identifiers, single-quoted strings with '' escaping, and TRUE/FALSE literals. It runs on PostgreSQL, SQLite, and MySQL (in ANSI_QUOTES mode).
How are column types chosen?
By scanning the values per key: all integers → INTEGER, any float → REAL, all booleans → BOOLEAN, everything else → TEXT. Nulls don't affect the choice.
How are single quotes in strings escaped?
Doubled, per the SQL standard: it's becomes 'it''s'. Backslash escaping is deliberately avoided: it's not portable.
What happens to nested objects and arrays?
They're serialized to compact JSON and stored as a text value. Query them with your database's JSON functions, or flatten first for real columns.
Can I go the other way?
Yes. SQL to JSON parses INSERT statements back into a JSON array.
Is my data uploaded?
No. Generation runs entirely in your browser; check DevTools for zero network requests.