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.
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.Related tools
Last updated: 2025-01-15