SQL to JSON
Convert SQL INSERT statements into JSON.
Paste one or more INSERT INTO statements above to see the JSON, or load the sample. The conversion runs entirely in your browser.
How to use SQL to JSON
What this tool does
This tool reads SQL INSERT INTO statements and turns the rows inside them into
JSON. Paste one statement or many; for each one it parses the table name, the
optional column list and every VALUES tuple, then emits a JSON array. When a
statement names its columns, each row becomes an object keyed by column name. When
it does not, each row becomes an array of values. The whole conversion runs in your
browser — the SQL never leaves your machine.
Why you might need it
Database dumps, migration files and seed scripts are full of INSERT statements,
but plenty of tools want JSON instead: a test fixture, a mock API response, a
front-end data file, or input for another converter. Retyping rows by hand is slow
and error-prone. Pasting the SQL you already have and copying clean JSON out is
immediate. It is also a quick way to read a dense dump — JSON’s indentation makes
the structure of each row far easier to scan than a long VALUES line.
How to use it
- Paste your SQL
INSERTstatements into the input box, or click Load sample to see the expected shape. - The JSON output appears instantly below, pretty-printed with two-space indentation.
- Check the row count beside the output to confirm every tuple was picked up.
- Click Copy to put the JSON on your clipboard.
- If something is wrong, read the error message — it names the exact problem — fix the SQL, and the output refreshes.
Formats explained
A statement like INSERT INTO users (id, name) VALUES (1, 'Ada'), (2, 'Alan');
produces an array of two objects: {"id": 1, "name": "Ada"} and
{"id": 2, "name": "Alan"}. The same statement without the (id, name) column list
produces [1, "Ada"] and [2, "Alan"] instead, because the keys are unknown.
Inside a value, NULL becomes null, TRUE and FALSE become booleans, bare
numbers become JSON numbers, and single-quoted text becomes a string. An escaped
quote — two single quotes in a row, as in 'O''Brien' — is decoded to the single
character O'Brien.
Common pitfalls
The parser is quote-aware, so commas and parentheses inside a string literal are
safe. The errors you are most likely to hit are structural: a string that was never
closed, a VALUES list with a stray or missing parenthesis, or a row whose number
of values does not match the number of named columns. Each of those produces a
specific message rather than silently dropping data. Note that this is a focused
INSERT converter, not a full SQL engine — SELECT, UPDATE, CREATE TABLE and
similar statements are ignored, and database-specific functions used in place of a
literal value are kept as plain text rather than evaluated.
Tips and advanced use
You can paste an entire seed file at once; comments are stripped automatically and
every INSERT is collected into a single JSON array, which is handy for building
one fixture from many statements. If you need objects rather than arrays, make sure
each statement includes its column list. After converting, you can drop the JSON
straight into a formatter or schema generator. And because the tool is fully
client-side, converting INSERT statements pulled from a production database carries
no risk of that data being transmitted anywhere.
Frequently asked questions
Is my SQL sent to a server?
Which SQL statements does this tool understand?
What happens if my INSERT has no column list?
How are strings, NULL and booleans handled?
Why does my SQL show an error?
Related tools
JSON Schema Generator
Infer a JSON Schema from a sample document.
ASCII Table Reference
Browse the full ASCII character reference table.
HTTP Status Codes
Look up every HTTP status code and its meaning.
HTTP Headers Reference
Reference common HTTP request and response headers.
MIME Type Lookup
Look up MIME types by file extension.
EyeDropper Color Picker
Pick any color on screen with the EyeDropper API.