JSON to SQL & SQL to JSON Converter
Generate INSERT, upsert or UPDATE statements, or turn SQL inserts and dumps back into JSON.
Input JSON
SQL Output
About the JSON ⇄ SQL
Turn an array of JSON objects into ready-to-run SQL, or swap direction to read the rows in INSERT statements or a pg_dump or mysqldump file as JSON. Column names come from the object keys, values are escaped safely, and a CREATE TABLE statement can be generated too.
How to use it
- Paste a JSON array of objects to generate SQL, or press Swap and paste INSERT statements or a dump to read them as JSON.
- The result appears as you type; rename columns in the Columns table if needed. Swap moves the result into the input so you can convert it back.
- Use Options for the dialect, table, operation, batching and CREATE TABLE (or, for SQL to JSON, tables and string escapes), then copy or download the file.
Frequently asked questions
Which databases are supported?
PostgreSQL, MySQL, SQLite and SQL Server. The dialect controls identifier quoting, string escaping, column types and upsert syntax.
Are values escaped?
Yes. Strings are quoted and single quotes are escaped. By default nested objects and arrays are stored as JSON text; Options can flatten or skip them instead.
What can SQL to JSON read?
INSERT and REPLACE statements (including multi-row, IGNORE and upsert forms), UPDATE … SET … WHERE, SQL Server MERGE with VALUES, and the COPY blocks in pg_dump files. A CREATE TABLE in the same SQL supplies column names and types, so 1/0 in boolean columns become true and false and JSON columns become JSON. Other statements are skipped, and nothing is ever run.