Paste INSERT INTO statements, optionally with their CREATE TABLE, and get each table's rows as a JSON array of objects. Works with MySQL, PostgreSQL, SQLite and SQL Server syntax, handles multi-table dumps and exports any table as CSV.
Last updated:
Converts automatically as you type. Your SQL is never uploaded or executed.
Advertisement
Advertisement
How to use the SQL to JSON Converter
Paste your SQL: INSERT statements, a full dump, or click Sample. You can also upload a .sql file.
Pick the table to show if the SQL contains more than one, or choose "All tables".
Adjust the options: indentation, booleans, JSON columns and backslash escapes.
Check the status line for skipped statements or errors with their line numbers.
Copy or download the JSON, or export the selected table as CSV.
How SQL values map to JSON
SQL value
JSON value
Notes
'text', N'text', E'text'
"text"
'' becomes one quote; backslash escapes in MySQL mode and E'' strings
42, -15.50, 1.5e3
42, -15.5, 1500
Integers above 253 − 1 can be kept as strings
NULL
null
DEFAULT is also written as null
TRUE / FALSE
true / false
1/0 too, in BOOLEAN, BOOL, BIT(1) and TINYINT(1) columns
'{"a":1}' in a JSON/JSONB column
{"a": 1}
Needs a CREATE TABLE that declares the column as JSON
'2024-01-15'::date, CAST('5' AS INT)
"2024-01-15", "5"
The literal inside a cast is used
NOW(), CURRENT_TIMESTAMP
"NOW()"
Expressions cannot be evaluated, so they are kept as text
mysqldump writes extended INSERTs without column lists. Keep the CREATE TABLE statements in the input so the JSON gets real column names instead of column1, column2.
pg_dump writes COPY blocks by default. Run it with --inserts or --column-inserts to produce INSERT statements this tool can read.
SQLite: the .dump command in the sqlite3 shell outputs CREATE TABLE and INSERT statements that convert directly.
Statements such as SET, LOCK TABLES, DROP TABLE and CREATE INDEX are ignored safely. The SQL is only parsed, never executed.
Frequently asked questions
What SQL does the converter understand?
INSERT INTO, INSERT IGNORE and REPLACE INTO statements with one or many rows in VALUES, plus CREATE TABLE statements, which are used to name columns and detect boolean and JSON types. Other statements such as SET, LOCK TABLES, DROP or CREATE INDEX in a dump are skipped and counted in the status line.
Where do the JSON keys come from?
From the column list in the INSERT statement, for example INSERT INTO users (id, name) VALUES ... If the INSERT has no column list, the columns of a CREATE TABLE for the same table are used. Without either, keys are named column1, column2 and so on.
How are values converted?
Quoted strings become JSON strings, numbers become JSON numbers, NULL becomes null and TRUE/FALSE become true/false. Values in BOOLEAN, BOOL or BIT(1) columns can be turned from 1/0 into true/false, and JSON or JSONB column values can be parsed into nested objects. Function calls like NOW() are kept as text.
What are backslash escapes?
MySQL treats a backslash inside a string as an escape character, so 'It\'s' means It's and \n means a line break. PostgreSQL, SQLite and SQL Server treat backslashes literally and only use '' to escape a quote. Auto mode turns backslash escapes on when the SQL looks like MySQL, for example when it uses `backtick` quoting.
Can I convert a whole database dump?
Yes. Paste or upload the dump file. Every table with INSERT statements gets its own array; select a table in the menu or choose All tables to get one JSON object keyed by table name. Everything runs locally, so very large dumps are limited only by your browser's memory.
Why are some numbers quoted in the JSON?
Integers larger than 9,007,199,254,740,991 cannot be represented exactly as JSON numbers in JavaScript, so they are kept as strings to preserve every digit. Turn the option off if you prefer plain numbers.
Are all the tools on FreeToolCabin tested for quality and accuracy?
Yes! Every tool on our site undergoes automated Q/A testing in real browser environments to ensure high precision, correct output, and zero errors. If you happen to spot a bug or have a suggestion, please contact us at [email protected] and our team will review it right away.