Free Online SQL (INSERT Statements) to JSON Converter

Paste one or more SQL INSERT statements below to extract the values into a clean JSON array.

Input Ready

Input statistics are available via the Stats button above this field.

Output

Output statistics are available via the Stats button above this field.

Results are provided for informational purposes only and may contain errors. Please verify important information independently. Use of this tool is at your own risk.

What the SQL (INSERT Statements) to JSON Converter does

The SQL to JSON Converter reads SQL INSERT statements and returns the inserted rows as a JSON array. The column list of each INSERT becomes the object keys, and every row in the VALUES clause becomes one object.

Numbers stay numbers, quoted strings become JSON strings and NULL becomes null, so the result can go straight into a script, a test fixture or an API request. Several INSERT statements and multi-row VALUES lists are combined into one array.

When to use it

  • You have a snippet of a database dump and need the rows as data in JavaScript, Python or a REST call.
  • Turning seed or migration files into JSON fixtures for unit tests.
  • Reviewing what a script would insert before running it, then exporting the same rows with the JSON to CSV Converter.
  • Moving a few rows between two databases that do not share an export format, using JSON as the common middle step.

Worked example

Input

INSERT INTO users (id, name, email) VALUES
  (1, 'Ana', 'ana@example.com'),
  (2, 'Ben', 'ben@example.com');

Output

[
  {
    "id": 1,
    "name": "Ana",
    "email": "ana@example.com"
  },
  {
    "id": 2,
    "name": "Ben",
    "email": "ben@example.com"
  }
]

Common questions about the SQL (INSERT Statements) to JSON Converter

Which SQL statements are supported?

INSERT INTO ... VALUES statements, with or without an explicit column list, including several rows per statement. SELECT, UPDATE, CREATE TABLE and stored procedures are not data, so they are not converted.

Does it work with a full database dump?

Yes, as long as the dump uses plain INSERT statements and stays under 5 MB. Schema statements in the dump are skipped; for very large dumps, convert one table at a time.

What if an INSERT has no column list?

Then there are no names to use as JSON keys, and the converter reports that it could not parse the statement. Add the column list, for example INSERT INTO users (id, name) VALUES ..., and convert again.

Frequently Asked Questions

Does it work with a full SQL dump file?

It parses INSERT ... VALUES statements specifically. CREATE TABLE statements and other SQL commands in the same paste are ignored.

Is this tool free?

Yes, it's free to use. No signup, no email required. Get results on this page.

How do I get my result?

Use the tool on this page. Your result appears here; no email delivery is required.