Skip to content

SQL to JSON

Convert SQL INSERT statements into a JSON array of objects.

Input
Output

SQL to JSON

Paste one or more SQL INSERT INTO statements and this tool turns them into a JSON array of objects, one per row, using the column names as keys. It handles multi-row VALUES lists, several statements at once, and the quoting variations you see across MySQL, PostgreSQL and SQL Server dumps — single-quoted string values with '' escaping, and identifiers wrapped in backticks, double quotes or square brackets.

Choose "Grouped by table" instead of the default flat array when your input mixes INSERT statements for several tables — rows are then collected under each table's own name in one JSON object. Type inference casts numeric literals to JSON numbers, TRUE/FALSE to booleans and NULL to JSON null; turn it off to keep every value exactly as it read in the SQL, as a plain string. Pretty-printing adds two-space indentation for readability, or turn it off for a compact, minified result.

The parser is a small hand-written tokenizer built for this one job — no SQL engine runs anywhere and nothing is ever executed. If a statement can't be parsed, the tool reports the line and column and shows the offending fragment instead of failing silently or guessing at a fix. A row with a different number of values than the declared columns is reported the same way, so a typo in a migration script or a seed file is easy to spot.

Everything runs in your browser. The SQL you paste — table names, seed data, migration fixtures — never leaves your device, so it is safe to use on production dumps or anything containing real customer data. When you are done, copy the JSON, download it as a file, or send it straight to another tool such as a JSON formatter.

FAQ

Which SQL dialects does it understand?
Standard INSERT INTO statements with single-quoted strings, NULL/TRUE/FALSE literals, and backtick-, double-quote- or bracket-quoted identifiers — the common ground between MySQL, PostgreSQL and SQL Server dumps. It doesn't run a real SQL engine, so expressions, subqueries or function calls inside VALUES aren't supported.
What happens with multiple INSERT statements in one input?
Every statement is parsed and its rows are added to the result — either as one flat array (the default) or grouped by table name if you switch the output shape, with rows from repeated statements against the same table merged into one list.
What if a statement doesn't declare column names?
Columns are named col1, col2 and so on based on position, so the JSON still gets one key per value.
How does type inference work?
With it on, numeric literals become JSON numbers, TRUE/FALSE become booleans and NULL becomes JSON null. Turn it off to keep every value exactly as written, as a string.
Is my SQL uploaded anywhere?
No. Parsing happens entirely in your browser — the SQL you paste, including any real data it contains, never leaves your device.