SQL to JSON

Turn SQL INSERT statements from a database dump into JSON that keeps column names.

Add SQL and click Convert to see the JSON here.

How SQL to JSON works

Reads rows from SQL INSERT statements, like the ones in a database dump, and turns them into JSON. Each row becomes an object with the column names as keys. The SQL is only read, never run.

Column names come from the column list of the INSERT. If it has none, names come from a CREATE TABLE for that table earlier in the text. Otherwise columns are named column_1, column_2 and so on.

Input to SQL to JSON

  • Paste or type SQL into the input box, or upload or drop a .sql or .txt file.
  • Other statements and comments are skipped. INSERT ... SELECT has no values to read, so it is skipped too.
  • Read \' and \n as escapes (MySQL dumps) is on by default. Turn it off for PostgreSQL or SQLite dumps, where a backslash is a plain character.
  • Files up to 20MB and 1,000,000 rows. Everything runs in your browser, so your data never leaves your computer.

Output from SQL to JSON

  • JSON indented with 4 spaces. One table gives a list of objects. Many tables give one object with a list for each table name.
  • Numbers become JSON numbers, NULL becomes null and TRUE/FALSE become true/false. Very long whole numbers, like IDs, stay as text so no digits are lost.
  • Function calls like NOW() are kept as text. If the SQL has an error, you see its line and column.
  • Copy it or download it as output.json.