{ } JSON Workbench0 network requests. Check DevTools

"JSON to SQL":{ }

Paste a JSON array of objects and get ready-to-run SQL: a CREATE TABLE with column types inferred from your data, plus a multi-row INSERT with standard-compliant quoting. Works for Postgres, SQLite, and MySQL. 100% in-browser. Nothing is uploaded.

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_QUOTES or swap " for backticks if needed.
  • SQLite has no BOOLEAN storage class: TRUE/FALSE become 1/0 automatically.
  • NaN/Infinity are 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 valueSQL output
4242 (column INTEGER)
9.59.5 (column REAL)
trueTRUE (column BOOLEAN)
"it's"'it''s' (column TEXT)
null / missing keyNULL
{"k":1} / arrays'{"k":1}' JSON text

How to use

  1. Paste a JSON array of objects into the Input pane (or load a file / the sample).
  2. You get a CREATE TABLE with inferred column types plus one multi-row INSERT.
  3. Column types are inferred from the data: INTEGER, REAL, BOOLEAN, or TEXT.
  4. Strings are single-quoted with quotes doubled (''); nested objects are stored as JSON text.
  5. Copy the SQL into psql, the sqlite3 shell, MySQL, or a migration file.

Examples

Array of objects → CREATE TABLE + INSERT

Input
[{ "id": 1, "name": "Ann" }, { "id": 2, "name": "Bob" }]
Output
CREATE TABLE "data" (
  "id" INTEGER,
  "name" TEXT
);

INSERT INTO "data" ("id", "name") VALUES
  (1, 'Ann'),
  (2, 'Bob');

Quotes, nulls and booleans

Input
[{ "note": "it's fine", "score": null, "active": true }]
Output
INSERT INTO "data" ("note", "score", "active") VALUES
  ('it''s fine', NULL, TRUE);

Nested objects → JSON text column

Input
[{ "id": 1, "meta": { "tags": ["a"] } }]
Output
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.

Related tools