Skip to content
TypeParser
All tools

SQL Insert to JSON

Parse SQL INSERT statements to JSON.

beats codebeautify.org edge: Multi-row + column-aware
SQL INSERT
paste SQL
Guide

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

  1. Tokenize the SQL.
  2. Find each INSERT INTO.
  3. Pull the column list from the parens after the table name.
  4. Parse the VALUES list — each tuple becomes one object.
  5. 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, Postgres RETURNING. 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?
Standard 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?
Both 'O''Brien' (SQL doubled-quote) and 'O\'Brien' (backslash-escape) parse correctly.
How are NULL values rendered?
JSON null. Distinguished from the string 'NULL'.
Numeric literals?
Plain 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?
Stay as strings (ISO 8601 if that is what your SQL uses). Date detection is opt-in.
Can it process a big SQL dump?
Up to a few MB cleanly. For multi-GB dumps, stream through a proper parser like mysqldump-to-json.

Related tools

Last updated: 2025-01-15