About SQL Insert to JSON
Read SQL <code>INSERT INTO ... VALUES (...)</code> statements and produce a JSON array of objects matching the column list. Handles multi-row inserts, NULL, escaped strings, numeric literals, date strings. Useful when you have a SQL dump and want JSON for fixtures or analysis.
Working with JSON inside SQL
This tool covers the offline path — turning a SQL INSERT dump into JSON. If instead you want to read or emit JSON from a live database, use the native functions:
- SQL Server (JSON support added in 2016):
SELECT ... FOR JSON PATHbuilds JSON from rows;OPENJSON(@json)shreds JSON into rows;JSON_VALUE(col, '$.key')extracts a scalar. To build a table from JSON:SELECT * INTO t FROM OPENJSON(@json) WITH (id int, name nvarchar(100)). - PostgreSQL: store as
jsonb, query with->/->>, build withrow_to_json()andjson_agg(). - MySQL: the
JSONtype plusJSON_EXTRACT()/->>. - Escaping: in SQL Server JSON paths, a key containing
]or other reserved characters must be wrapped in double quotes —$."weird]key".
For the reverse (JSON → SQL) at scale, prefer the database’s own bulk importer (bcp, COPY, LOAD DATA) over generated INSERT statements.
Common workflow this solves
You have a SQL dump from a teammate. You want JSON to load into your dev environment, or to feed into a fixture, or to inspect in a tool that does not speak SQL. Cleaner than spinning up a database just to extract rows.
How parsing works
- Tokenize the SQL.
- Find each
INSERT INTO. - Pull the column list from the parens after the table name.
- Parse the
VALUESlist — each tuple becomes one object. - Coerce literals: numbers, strings, booleans, NULL, dates per setting.
The output is one JSON array per input statement, or a single combined array if all statements target the same table.
What it can’t do
INSERT ... SELECT— needs query execution, not just parsing.- Vendor-specific syntax — Oracle
INSERT ALL, MS SQL stored procedures, PostgresRETURNING. Strip these before pasting. - Computed columns — defaults, sequences, triggers. The output reflects the literal values.
- JSON columns — content stays as strings; pass through JSON Formatter to nest.
Common workflows
Fixture from production. Coworker dumps a row’s SQL. Paste, convert, drop into your test fixture file.
Migrate from SQL to NoSQL. Dump table contents, convert, ingest into MongoDB / DynamoDB / Firestore. Skip the round-trip through a real ETL.
Inspect a tabular dump in JSON tooling. Easier to grep, filter, and reshape JSON than SQL with a text editor.
Frequently asked questions
What syntax is supported?
INSERT INTO table (col1, col2) VALUES (v1, v2), (v3, v4). Both single-row and multi-row. MySQL, Postgres, SQLite syntax all work; Oracle's INSERT ALL needs preprocessing.What about escaped quotes?
'O''Brien' (SQL doubled-quote) and 'O\'Brien' (backslash-escape) parse correctly.How are NULL values rendered?
null. Distinguished from the string 'NULL'.Numeric literals?
123 becomes a JSON number; quoted '123' stays a string. Decimals likewise — adjust with the type-coercion toggle if your schema disagrees.Dates and timestamps?
Can it process a big SQL dump?
mysqldump-to-json.How do I query, store, or parse JSON inside SQL itself?
SELECT ... FOR JSON PATH, and read JSON into rows with OPENJSON(@json); extract a value with JSON_VALUE(col, '$.key'). PostgreSQL: use jsonb columns and the -> / ->> operators, or row_to_json() / json_agg() to build JSON. MySQL: the JSON type plus JSON_EXTRACT(). This tool handles the offline direction — turning an INSERT dump into JSON without a running database.How do I convert JSON back to SQL, or build a table from JSON?
CREATE TABLE + INSERT statements from the keys of your array: each object key becomes a column, each object a row. In SQL Server, SELECT * INTO newtable FROM OPENJSON(@json) WITH (...) creates and fills a table in one shot. Paste your JSON into a generator or use the database's native importer for large sets.Related tools
Last updated: 2026-07-04