SQL results · INSERT parser · Export snippets — 3 modes

Convert SQL to JSON
Paste results, parse
INSERTs, get code.

Three modes for every SQL→JSON need: paste query results to get a JSON array, extract JSON from INSERT statements, or get ready-to-run MySQL, PostgreSQL and SQLite export snippets.

Your data never leaves your browser
SQL results → JSON array
INSERT statements → JSON objects
MySQL · PostgreSQL · SQLite snippets
Always free
SQL to JSON — 3 modes   100% client-side
Paste SQL query results here
  JSON ready

      
Three ways to convert SQL to JSON

Each mode targets a different workflow — choose the one that matches how you're working.

Mode 1 — SQL Results

Copy the output of any SQL query from your database client and paste it here. MySQL Workbench, DBeaver, TablePlus and pgAdmin all copy results as tab-separated rows. The converter auto-detects the separator and outputs a JSON array of objects.

Input — pasted from DBeaver
id  name   active
1   Alice  1
2   Bob    0
Output
[{"id":1,"name":"Alice","active":true},
 {"id":2,"name":"Bob","active":false}]
Mode 2 — INSERT Parser

Paste INSERT INTO statements from a SQL dump file. The parser extracts column names from the INSERT header and values from each VALUES clause — handling quoted strings, NULL values, escaped quotes and batch INSERTs with multiple value rows.

Input — from mysqldump
INSERT INTO users (id, name)
VALUES (1, 'Alice'), (2, 'Bob');
Output
[{"id":1,"name":"Alice"},
 {"id":2,"name":"Bob"}]
Mode 3 — Code Snippets

Get ready-to-run SQL queries and code for exporting a table as JSON directly from your database. Covers native JSON functions in MySQL, PostgreSQL and SQLite, plus Node.js and Python patterns for programmatic export.

PostgreSQL output
SELECT json_agg(row_to_json(t))
FROM (SELECT * FROM your_table) t;
When do you need SQL to JSON?

The most common workflows where SQL data needs to become JSON.

API response building

REST APIs return JSON but data lives in SQL databases. Mode 3 gives you the native JSON export query for your database — run it directly and your API endpoint gets a pre-serialised JSON array without any ORM or application-layer serialisation code.

Database migration to NoSQL

Migrating from MySQL or PostgreSQL to MongoDB, Firestore or DynamoDB requires exporting relational data as JSON documents. Mode 1 lets you copy query results and convert them instantly — no mysqldump, no scripting, no intermediate file format.

Reading SQL dump files

SQL dump files contain INSERT statements that are unreadable without a database. Mode 2 parses the INSERT statements and outputs JSON — letting you inspect the data in a JSON viewer, convert it to CSV, or load it into a different system without spinning up a database.

Test data extraction

Development and testing often requires exporting a subset of production data as JSON fixtures. Copy the query results for your test subset in Mode 1 — the JSON array is immediately usable as a fixture file for Jest, Vitest, pytest or any testing framework.

Native JSON export functions by database

The built-in SQL functions for exporting query results as JSON — no application code needed.

DatabaseJSON array exportSingle row as object
MySQL 5.7.22+ SELECT JSON_ARRAYAGG(JSON_OBJECT('id', id, 'name', name)) FROM t JSON_OBJECT('id', id, 'name', name)
PostgreSQL 9.4+ SELECT json_agg(row_to_json(t)) FROM (SELECT * FROM t) t row_to_json(t.*)
SQLite 3.38+ SELECT json_group_array(json_object('id', id, 'name', name)) FROM t json_object('id', id, 'name', name)
SQL Server 2016+ SELECT * FROM t FOR JSON AUTO SELECT * FROM t FOR JSON PATH, WITHOUT_ARRAY_WRAPPER
Related JSON tools
Popular searches
sql to json mysql to json convert sql to json sql query to json postgresql to json sqlite to json sql results to json mysql to json converter postgresql to json array sql table to json sql to json online export mysql to json sql insert to json postgresql select to json

SQL converted in
your browser. No database needed.

All three modes run entirely in JavaScript — no connection to any database, no upload to any server. Paste your query results or INSERT statements and get JSON instantly. The code snippets are static — generated from your dialect and table name selection without any API call.

The INSERT parser handles real-world SQL dump syntax: single and batch INSERTs, quoted strings with escaped quotes, NULL values, and mixed spacing. It reads column names from the INSERT header and matches them to values in each VALUES clause.

Auto-detect separator
Tab, pipe or comma — the results mode detects which separator your database client used when you copied the query output.
Real INSERT parser
Handles batch INSERTs with multiple value rows, NULL values, escaped single quotes, and optional CREATE TABLE for column names.
Native JSON export queries
Mode 3 gives you the exact SQL query using native JSON functions — JSON_ARRAYAGG for MySQL, json_agg for PostgreSQL, json_group_array for SQLite.
47 tools, always free
No row limits, no watermarks, no account. Funded by non-intrusive display advertising only.
Frequently asked questions
Common questions about converting SQL to JSON.
How do I convert SQL query results to JSON?
Copy the results of your SQL query from your database client (MySQL Workbench, DBeaver, TablePlus, psql), paste them into the SQL Results mode, and click Convert. The tool auto-detects tab, pipe or comma separators and outputs a JSON array with column names as keys.
How do I export MySQL data to JSON?
In MySQL 5.7.22+: SELECT JSON_ARRAYAGG(JSON_OBJECT('col1', col1, 'col2', col2)) FROM your_table. Use the Code Snippets mode above to generate the exact query for your table and MySQL version. For a file export, the CLI snippet uses mysql command with -e flag and redirects to a .json file.
How do I convert PostgreSQL results to a JSON array?
SELECT json_agg(row_to_json(t)) FROM (SELECT * FROM your_table) t; returns a JSON array of objects. For JSONB output: SELECT jsonb_agg(to_jsonb(t)) FROM your_table t. Both work in PostgreSQL 9.4+. Use the Code Snippets mode to get the full query with your table name.
How do I parse INSERT statements to get JSON?
Paste your INSERT INTO statements into the INSERT Parser mode. Include a CREATE TABLE statement at the top if you want column names extracted from there — otherwise the parser reads column names from the INSERT INTO header. Batch INSERTs with multiple value rows and NULL values are both supported.
Is my SQL data safe when using this converter?
Yes. All three modes run entirely in your browser. Your SQL data is never uploaded to any server. Open the Network inspector — you will see zero outbound data requests during conversion.
Go up