SQL to JSON Converter
This SQL to JSON converter reads the rows out of INSERT … VALUES statements and turns them into an array of JSON objects keyed by the column list. The statements are tokenised rather than pattern-matched, which is what makes it reliable: a comma inside a string, an escaped apostrophe, a function call in a value or a semicolon inside a text column cannot corrupt the result. Several INSERTs into the same table are merged, so a dump split across dozens of statements still gives you one array. SQL literals keep their types — numbers stay numbers, TRUE and FALSE become booleans, NULL becomes JSON null — and integers too large for JavaScript to hold exactly are kept as text so no digits are lost.
How it works
Turns INSERT … VALUES statements into an array of objects keyed by the column list. Several INSERTs into the same table are merged, so a dump split across many statements produces one array.
SQL literals keep their types: numbers stay numbers, TRUE and FALSE become booleans, and NULL becomes JSON null rather than the string "NULL". Integers too large for JavaScript to represent exactly are kept as text so no digits are lost.
The conversion runs entirely in your browser — nothing you paste or upload is sent to a server.
How to convert SQL to JSON
- Paste your
INSERTstatements into the input on the left, or upload a.sqldump. - If the dump covers several tables, step through them with the table number box.
- Copy the array of objects, or download it as a
.jsonfile.
Why the parsing has to be real
Splitting a dump on commas and quotes almost works, which is what makes it dangerous. Every one of these breaks a pattern-matching approach:
'Chen, Ada'— a comma inside a string is not a column separator.'O''Brien'— a doubled quote is one apostrophe, not the end of the value.CONCAT('a', 'b')— the comma is inside a function call, not between values.'end of statement; really'— a semicolon inside a string is not a statement boundary.
This tool tokenises the SQL first, so each of those is recognised for what it is before anything is split.
Types survive the conversion
SQL literals carry their type in the syntax, so there is no guessing to do: an unquoted 42 becomes
the number 42, TRUE becomes a boolean, and NULL becomes JSON null rather
than the four-character string.
Very large integers are the one deliberate exception. JavaScript cannot represent an integer beyond about 9 quadrillion exactly, so a 20-digit ID would come back with its last digits changed. Those are kept as strings instead, which loses the type but keeps every digit.
Statements that are skipped
INSERT … SELECT takes its rows from a query rather than from literals, so there is nothing to read
without running it. Those statements are counted and reported under the output rather than silently ignored, so
you know the result is incomplete.
Common use cases
- Turning a production dump into fixtures for a test suite.
- Getting seed data out of a migration file and into an API mock.
- Inspecting the contents of a dump without restoring it to a database.
Frequently asked questions
How do I convert SQL to JSON?
Paste your INSERT statements into the left panel or upload a .sql dump. An array of JSON objects appears on the right, keyed by the column list in the statement.
What kinds of SQL can it read?
INSERT … VALUES statements with literal values, which is what a data dump consists of. INSERT … SELECT statements have no literal rows to read, so they are counted as skipped and reported below the output.
What if my dump has several tables?
Each table is collected separately and the note under the output tells you how many were found. Use the table number box to step through them.
Are escaped quotes handled?
Yes. Both conventions are supported: a doubled quote as in ’’ and a backslash escape. A value stored as ‘O’’Brien’ comes back as O’Brien.
Do numbers stay numbers?
Yes, along with booleans and NULL. Very large integers are the one exception — they are kept as strings, because turning them into JavaScript numbers would silently change the last few digits.
Is my dump uploaded anywhere?
No. The file is read and parsed entirely in your browser, so production data never leaves your device.
Related tools
SQL to CSV Converter
This SQL to CSV converter turns INSERT statements into spreadsheet rows, escapes and all.
JSON to SQL Converter
This JSON to SQL converter turns an array of objects into escaped INSERT statements.
SQL Formatter & Beautifier
This SQL formatter breaks a one-line query into readable clauses, across a dozen dialects.