JSON to SQL
Turn a JSON array of objects into ready-to-run INSERT statements for MySQL, PostgreSQL or SQLite.
Your data stays on your device
Input — JSON
- characters
- 0
- lines
- 0
- size
- 0 B
Output — SQL
- characters
- 0
- lines
- 0
- size
- 0 B
Options
About this tool
Seeding a table from a JSON export usually means writing INSERT statements by hand. This tool builds them for you: it takes the union of keys across your objects as the column list and emits one row per object, with values quoted and escaped correctly for the dialect you choose.
It only produces SQL text — it never connects to a database or runs anything. Strings are escaped by doubling single quotes, nulls become NULL, booleans follow each dialect, and nested objects or arrays are stored as JSON strings.
Dialect choice affects more than cosmetics. MySQL quotes identifiers with backticks while PostgreSQL and SQLite use double quotes, and SQLite has no native boolean, so true and false are written as 1 and 0. Picking the right dialect means the generated statements paste straight into your client without hand-editing.
Objects in a JSON array rarely all carry the same keys. The column list is therefore the union of every key seen across the whole array, and any row missing one of those keys gets NULL for that column — so a ragged export still produces one consistent, runnable statement set.
How to use this tool
- Paste a JSON array of objects, or a single object.
- Enter the target table name and pick MySQL, PostgreSQL or SQLite.
- Choose one combined INSERT or one statement per row.
- Press Generate SQL, then copy or download the statements.
Key features
- MySQL, PostgreSQL and SQLite dialects
- Correct identifier quoting per dialect
- Single multi-row INSERT or one statement per row
- Single quotes in strings escaped safely
- Column list built from the union of all keys
Example
Input — JSON
[{"id":1,"name":"Ada"},{"id":2,"name":"Alan"}]Output — SQL
INSERT INTO my_table (`id`, `name`) VALUES
(1, 'Ada'),
(2, 'Alan');Good to know
- It generates INSERT statements only. Table creation, types and constraints are up to you.
- Values are formatted as literals; it does not use parameterised queries, so review the output before running it on real data.
Frequently asked questions
Does this run against my database?
No. It produces SQL text only. Nothing connects to a database and nothing is executed.
How are nested objects handled?
Nested objects and arrays are stored as JSON strings in the column, since a single column cannot hold a structured value directly.
What if objects have different keys?
The column list is the union of every key seen. Rows missing a key get NULL for that column.
Is the output safe to run directly?
Quotes inside string values are escaped by doubling them, which is the standard, portable form. Even so, treat generated SQL like any other script: read it before running it against real data, and prefer a transaction so you can roll back.
Why does SQLite output 1 and 0 instead of TRUE and FALSE?
SQLite has no dedicated boolean type and stores booleans as integers. MySQL and PostgreSQL both accept TRUE and FALSE, so those dialects use the keywords.
Can it create the table too?
No — it generates INSERT statements only. Column types, keys and constraints are design decisions that cannot be inferred safely from one example, so the schema stays yours to write.
Your data stays on your device
Your data is processed locally in your browser and is not uploaded to our server. This page keeps working after you go offline, because there is nothing to send.