toolqik

146 · JSON

SQL to JSON

Turn INSERT statements or a pasted query result table into a JSON array of rows.

Runs in your browser
Indent
Input
Options
JSON

  

About this tool

Turn SQL data into JSON for tests, fixtures, mock APIs or a quick look in a JSON viewer. It reads two kinds of input:

  • INSERT statements, as written by mysqldump, pg_dump --inserts, SQLite’s .dump or any SQL client’s “copy as INSERT”. Multi-row VALUES (…), (…), quoted identifiers, '' and backslash escapes, NULL, TRUE/FALSE and negative numbers are understood. If the INSERTs don’t list columns, column names are taken from a CREATE TABLE statement in the input.
  • Query results: the boxed tables printed by the mysql client, psql output, Markdown tables, and tab-separated rows copied from a grid in DBeaver, DataGrip, pgAdmin or MySQL Workbench. The first row is the header.

One table gives a JSON array of row objects; several tables give an object with one array per table. Values that aren’t plain literals, such as NOW(), are kept as text. Long integer IDs stay strings in result tables so no digits are lost.

To go the other way, the JSON to SQL converter writes CREATE TABLE and INSERT statements. Nothing is uploaded; this tool never connects to a database.

FAQ

How do I convert SQL INSERT statements to JSON?

Paste them above. Each row becomes a JSON object with the column names as keys.

Can I convert the output of a SQL query?

Yes. Paste the table printed by mysql or psql, or rows copied from your SQL client (tab-separated). The first row is used as column names.

What if my INSERT has no column list?

Include the CREATE TABLE statement and its column names are used. Otherwise the keys are column1, column2 and so on.

Does it connect to my database?

No. It only reads the text you paste, in your browser.

esc
↑↓ navigate↵ open