SQL INSERT to JSON Converter

Parse INSERT statements from a dump or script into a JSON array of objects, one per row, keyed by column name.

SQL INSERT statements
JSON
Runs locally in your browser

About the SQL INSERT to JSON Converter

A SQL dump is often the only export you have of a dataset. This converter reads every INSERT INTO table (columns) VALUES (...), (...) statement, including multi-row inserts and dumps with several tables, and produces JSON: for a single table, an array of row objects; for several, an object keyed by table name. Column names come from the column list; if it is absent, columns are named col1, col2 and so on.

Values are typed: unquoted numbers become numbers, TRUE and FALSE become booleans, NULL becomes null, and quoted strings have their doubled quotes unescaped. Comments are stripped before parsing so commented-out statements are ignored. Statements other than INSERT, such as CREATE TABLE or SET, are skipped.

For very large dumps the tool handles tens of thousands of rows; beyond that, load the dump into a database and export from there. To get a spreadsheet instead, SQL to CSV uses the same parser. The reverse tool generates INSERT statements from JSON.

How to use

  1. Paste the INSERT statements or upload the .sql file.
  2. Copy the JSON.
  3. Use the JSON tools to filter, sort or convert the data further.

Common questions

Does it run the SQL?
No. It parses the text of INSERT statements only; no database is involved.
What if the INSERT has no column list?
Columns are named col1, col2, and so on. Add the column list to the statement for real names.
Are functions like NOW() in values handled?
They are kept as the text "NOW()" since they cannot be evaluated.
Can it read MySQL dumps with backticks?
Yes. Backticks, double quotes and square brackets around identifiers are all removed.