SQL to JSON
Convert SQL INSERT data into JSON objects.
SQL to JSON Converter Online
The SQL to JSON converter reads the INSERT statements in a SQL script or database dump and outputs the rows as JSON objects. It is useful when you want to seed a NoSQL database, build fixtures for API tests, feed a JavaScript front end with data that currently lives in a MySQL backup, or simply read a dump in a friendlier format.
From rows to objects
Every value tuple in VALUES (…), (…) becomes one JSON object whose keys come from the statement's column list. For example:
INSERT INTO users (id, name, active) VALUES (1, 'Ada', TRUE), (2, 'Linus', NULL);
becomes [{"id": 1, "name": "Ada", "active": true}, {"id": 2, "name": "Linus", "active": null}]. Scripts that write to multiple tables produce an object such as {"users": [...], "orders": [...]}, keeping each table's rows separate.
Real JSON types
Because SQL literals carry their own type information, the converter does not need to guess: bare numbers become JSON numbers, NULL maps to null, booleans stay booleans, and anything in quotes is a string. Escaped quotes and backslash sequences are decoded, so the JSON contains the actual text that the database would have stored.
Options and preview
Choose two or four spaces, tabs, or minified output. Below the editors, a table preview shows the first table's rows so you can confirm that column names and values lined up correctly before copying the JSON.
Dialects and dumps
The parser accepts output from mysqldump, phpMyAdmin, pg_dump with --inserts, SQLite's .dump command, and SQL Server scripts. Comments, SET statements, LOCK TABLES, and schema changes are ignored.
Related tools
Validate or explore the output with the JSON Validator and JSON Viewer. Other targets: SQL to YAML, SQL to CSV, and SQL to XML. To turn JSON back into a spreadsheet, try JSON to Excel.
Frequently Asked Questions
What JSON structure do I get?
If the SQL inserts into one table, the output is an array of objects, one per row, keyed by column name. If it inserts into several tables, the output is an object whose keys are the table names and whose values are those row arrays.
Are numbers and NULLs converted to JSON types?
Yes. Unquoted numeric literals become JSON numbers, NULL becomes null, and TRUE/FALSE become booleans. Quoted values stay strings, so '00501' keeps its leading zeros.
Does it convert SELECT query results?
No. A SELECT statement contains no data by itself — only INSERT INTO … VALUES (and REPLACE INTO) statements carry rows, so those are what the converter reads. CREATE TABLE statements are used to name columns when an INSERT has no column list.