Skip to content
ZeroServer.tools

SQL to JSON

Convert SQL INSERT statements into a JSON array. Paste SQL, get JSON instantly.

or drop a file here

Convert SQL INSERT statements to JSON

Paste one or multiple INSERT INTO … VALUES statements and get back a JSON array of objects — column names become keys. Handles strings, numbers, booleans, and null. For the reverse direction, use JSON to SQL. To convert CSV data to JSON, try CSV to JSON.

Built and maintained by Meet Shah · Last updated

What this tool is used for

  • Turning INSERT statements from a dump into JSON for a modern service.
  • Extracting seed data from a migration into a fixture file.
  • Converting a colleague's SQL block into structured data you can inspect.
  • Getting data out of a dump without a database to load it into.
  • Producing JSON from statements generated by another tool.

Frequently Asked Questions

What does it parse out of a dump?
The column list and each value tuple of an INSERT statement, tokenised so that a comma inside a quoted string or a nested function call does not break the split. Each tuple becomes one JSON object keyed by the declared columns.
How is SQL NULL represented?
As JSON `null`, which is the one clean mapping in the whole conversion — both languages have a real null and mean roughly the same thing by it. Empty strings stay empty strings, so the distinction SQL draws between them survives.
Are numbers and booleans converted?
Yes, where the literal is unambiguous — an unquoted `30` becomes a number and `true` becomes a boolean. A quoted `'30'` stays a string, correctly, because that is what the SQL says. It is the one place the dump's own quoting carries type information.
What if there is no column list?
There is nothing to key the objects by. `INSERT INTO users VALUES (…)` relies on the table's column order, which is not in the dump — so the output falls back to positional keys and the real fix is exporting with the column list included.
How are escaped quotes handled?
SQL doubles a single quote inside a single-quoted literal, so `'O''Brien'` is one value containing an apostrophe. The tokeniser unwraps that before emitting JSON, where the same character needs no escaping at all — different conventions for the same problem.

Common errors and gotchas

  • Relying on statements that omit the column list, where the mapping depends on a table definition you may not have.
  • Mishandling escaped quotes inside string values, which a naive parse breaks on.
  • Converting SQL `NULL` to the string 'NULL' rather than JSON null.
  • Losing numeric versus string types, since SQL literals are quoted inconsistently.
  • Overlooking multi-row INSERT syntax, where one statement carries many records.

Related Converters tools

Private & free — this tool runs entirely in your browser.

IndieKitShip your Next.js startup in days.affiliate