Skip to content
ToolPlankDEV
Database Tools
100% In-Browser Execution

Updated:

SQL to JSON Converter

Paste SQL INSERT statements or a database dump and get JSON as you type. This sql to json converter reads several tables, column-less inserts, escaped quotes and pg_dump COPY blocks, and lists what it skipped. Nothing is uploaded.

Options:

SQL

Input
0 chars · 0 lines

JSON

Ready
Processing in browser...
0 chars · 0 linesUpdates as you type

Tables, skipped statements and notes

Tables found, statements that were skipped and rows that could not be read appear here.

Processed on your device. Your text is not sent to our servers.

More free tools you may need next.

Quick Guide

How to use SQL to JSON

Simple step-by-step instructions to get the exact output you need.

  1. 01

    Paste SQL or open a dump

    Paste INSERT statements, or open a .sql file such as a mysqldump or pg_dump export. Include the CREATE TABLE statements before the inserts when you have them, because they give the column names and types. Example loads a small MySQL dump, and the sample buttons load a pg_dump with COPY, SQL Server inserts and a file with problems.

  2. 02

    Check the tables and the JSON

    The JSON appears as you type. The panel shows every table that was found with its row count, the statements that were skipped and why, and any row that could not be read, with its line number.

  3. 03

    Choose the output and the type handling

    Get an array of objects, an object keyed by table, JSON Lines or arrays of arrays, and pick one table if you only need one. Decide whether tinyint(1) columns become true and false, whether JSON columns are parsed and how backslashes in strings are read.

  4. 04

    Copy or download the JSON

    Press Copy, or Download to save data.json or data.jsonl, then use it as test data, an API mock or input for another tool.

How to convert SQL to JSON

A SQL dump stores data as INSERT statements. To convert SQL to JSON, the tool reads each INSERT INTO table (columns) VALUES (...) statement, turns every row into an object that uses the column names as keys, and collects the rows by table. NULL becomes null, numbers stay numbers and text stays text.

JSON
INSERT INTO items (id, label) VALUES (1, 'ok'), (3, 'three');

[
  { "id": 1, "label": "ok" },
  { "id": 3, "label": "three" }
]

Dumps often contain user data, so the file is read in your browser and never uploaded, as the Privacy Policy describes. The tool reads statements. It does not run them, and it has no database engine.

Dumps with many tables and no column list

A real dump holds many tables. Each table that has rows gets its own entry, and with more than one table the output is an object keyed by table name. Pick one table in the Table box to export only that one.

mysqldump writes INSERT INTO users VALUES (1,'Ana',1), with no column names. The tool takes the names from the CREATE TABLE statement that came earlier in the same text. If there is none, the columns are called col1, col2 and so on, and a note says so. Schema-qualified names such as public.users and quoted names in backticks, double quotes or square brackets are read.

Statements that carry no rows, such as SET, LOCK TABLES, DROP, ALTER, CREATE INDEX and transaction commands, are skipped. The panel groups them by kind with the line of the first one, so you can see that nothing was missed silently.

Quotes, escapes and literals

Strings can be written in several ways and all of them are read: a doubled quote as in 'it''s', a backslash escape as in 'it\'s', and the \n, \t and \\ sequences. Backslash in strings has three settings. Auto, the default, reads backslashes as MySQL does, unless the text came from this site's JSON to SQL tool for another database. Escape reads backslashes as MySQL does. Plain reads them as normal characters, as standard SQL and PostgreSQL do.

  • N'...' and E'...' strings, and MySQL character set introducers such as _utf8mb4'...'.
  • Hex literals X'4142' and 0xBEEF, written as text such as 0x4142.
  • Typed literals such as DATE '2026-01-02' and casts such as 'x'::text or CAST('5' AS INT).
  • TRUE, FALSE and NULL, negative and exponent numbers, and comments in any position.

An expression the tool cannot evaluate, such as NOW() or UUID(), is kept as text and noted, because there is no database to run it. DEFAULT is read as null and noted.

Booleans, JSON columns and large numbers

MySQL stores true and false as tinyint(1). With the CREATE TABLE statement in the input, the option Read TINYINT(1) and BOOLEAN as true and false turns 1 and 0 in those columns into true and false. Columns declared as tinyint(4) or int are left as numbers. Without the CREATE TABLE statement the tool cannot know the type, so values stay as they are.

Columns declared json or jsonb hold JSON as text. Parse JSON columns turns the text into real JSON values, and a value that is not valid JSON stays a string with a note. Integers larger than 9,007,199,254,740,991 cannot be stored exactly as JSON numbers in JavaScript, so by default they are written as strings. Turn off Keep large numbers exact to get numbers.

JSON
[
  { "id": 1, "name": "Ana O'Neil", "active": true, "balance": 120.5, "prefs": { "theme": "dark" } },
  { "id": 2, "name": "Ben", "active": false, "balance": null, "prefs": null }
]

PostgreSQL dumps with COPY

pg_dump writes table data as COPY table (columns) FROM stdin followed by tab-separated lines and a line with a backslash and a dot. The tool reads those blocks. \N is null, and \t, \n and \\ are decoded. With the CREATE TABLE statement present, boolean values t and f become true and false, numeric columns become numbers and jsonb columns are parsed.

A row with a different number of values than the column list is skipped and reported with its line, so one damaged row does not stop the rest.

Output shapes

  • Array of objects: one object per row, or an object keyed by table when there are several tables.
  • Keyed by table: always an object with the table names as keys.
  • JSON Lines: one row per line, which suits large data. With several tables each line gets a _table key.
  • Arrays of arrays: a header row of column names, then the values.

The JSON can be indented with 2 or 4 spaces or a tab, or minified. Download saves data.json, or data.jsonl for JSON Lines.

  • Only INSERT ... VALUES and COPY data are read. INSERT ... SELECT, INSERT ... SET, UPDATE and DELETE need a database engine and are listed as skipped.
  • The input can be up to 2 million characters, so a very large dump has to be split into parts.
  • A string or quoted name that is never closed stops the conversion with the line number where it starts.
  • It reads statements, it does not validate the SQL, so check the result against the source.

To go the other way, use JSON to SQL. JSONL Viewer is useful for looking through JSON Lines output, and JSON to YAML converts the result to YAML.

Frequently Asked Questions

Technical Q&A for SQL to JSON

Common questions about edge cases, character encoding, and privacy guarantees.

Paste your INSERT statements or open a dump file. Each row becomes a JSON object and the result appears next to the input.

Yes, up to 2 million characters. It reads INSERT statements and COPY blocks for every table and skips statements that carry no rows, listing them.

The names are taken from the CREATE TABLE statement earlier in the input. Without one, the columns are called col1, col2 and so on.

Both a doubled quote, 'it''s', and a backslash quote, 'it\'s', are read. Set Backslash in strings to Plain if your data comes from standard SQL or PostgreSQL.

Yes. Type the table name in Table. Leave it empty to export every table that has rows.

Columns declared as tinyint(1), boolean or bit are read as booleans when the CREATE TABLE statement is in the input. Turn the option off to keep 0 and 1.

They are parsed into real JSON values when Parse JSON columns is on. Invalid JSON stays as text and a note is shown.

No. It only reads INSERT and COPY data. Running a query needs a database engine.

JavaScript numbers lose digits above 9,007,199,254,740,991. Writing such ids as strings keeps every digit, and you can turn the option off.

No. The file is read in your browser, so dumps with private data stay on your computer.