SQL to JSON

Convert SQL-style row data into JSON objects for modern apps.

Loading Smart Logic...

Quick Tip

Paste one or more INSERT INTO ... VALUES statements, including the column list.

About This Tool

Why use SQL to JSON?

Paste SQL INSERT statements and get JSON back. The column list in each INSERT becomes the keys, and each row tuple becomes an object — so INSERT INTO users (id, name) VALUES (1, 'John') gives you {"id": 1, "name": "John"}, not a bare array you then have to label yourself.

The parser is quote-aware, which is what makes it usable on real data. A value like 'Acme, Inc.' stays in one field instead of splitting into two, an escaped quote in 'O''Brien' comes back as a single apostrophe, and a semicolon inside a string does not end the statement early. Types are recovered too: numbers arrive as JSON numbers, NULL as null, and TRUE and FALSE as booleans rather than as the strings "NULL" and "TRUE". Multi-row INSERT statements and several statements in one paste both work.

Key Benefits

Column names become keys

The column list in the INSERT is read rather than discarded, so you get named objects instead of positional arrays.

Quote-aware parsing

Commas, semicolons and doubled quotes inside string literals are handled correctly instead of splitting the row in the wrong place.

Types recovered

Numbers become JSON numbers, NULL becomes null and TRUE/FALSE become booleans, so the output is usable without a cleanup pass.

How to use SQL to JSON

  1. 1

    Paste one or more INSERT INTO ... VALUES statements, including the column list.

  2. 2

    Convert; each row tuple becomes an object keyed by the column names.

  3. 3

    Check the output — numbers, booleans and nulls should have kept their types.

  4. 4

    Copy the JSON into your application, fixture or API request.

Best use cases

Turn a database dump into fixtures for a test suite.

Convert seed data from a migration into an API payload.

Inspect the contents of an INSERT statement in a readable form.

Move rows out of a SQL export into a JavaScript application.

SQL to JSON FAQs

What SQL does it understand?

INSERT INTO table (columns) VALUES (...) statements, including multi-row inserts and several statements in one paste. SELECT results, CREATE TABLE and stored procedures are not parsed.

What if the INSERT has no column list?

Without column names there is nothing to key the objects by, so that row is returned as an array of values in the original order.

Are data types preserved?

Yes. Numbers come through as JSON numbers, NULL as null, and TRUE and FALSE as booleans. Quoted literals stay strings, with doubled quotes unescaped.

Does a comma inside a text value break the parsing?

No. The parser tracks quoting, so a value like 'Acme, Inc.' stays in a single field. So does a semicolon inside a string.

Related Data Tools

More free data tools that work well alongside sql to json.