JSON to SQL INSERT statements
Paste a JSON object or an array of objects and get one `INSERT` statement per row. Column names come from the object keys, strings are single-quoted with quotes doubled for safety, numbers and booleans are emitted literally, and `null` becomes `NULL`.
It runs in your browser and escapes single quotes by doubling them, so pasted data with apostrophes will not break your statement or open an injection hole in a copy-paste workflow.
How to convert JSON to SQL INSERT statements
- Paste your JSON. Paste a single object or an array of objects. The union of all keys becomes the column list, so rows with missing keys get NULL.
- Click Generate INSERT SQL. One INSERT INTO mytable (...) VALUES (...); line is produced per object, with values typed: numbers and booleans literal, strings quoted, null as NULL.
- Copy and rename the table. Copy the SQL and replace mytable with your real table name. Nested objects and arrays are stored as JSON-string values.
Columns from keys
The column list is the union of every key across all objects in the array, in first-seen order. A row missing one of those keys gets NULL for it, so the statements stay column-aligned even when the JSON is ragged.
Value typing and escaping
Numbers and booleans (TRUE/FALSE) are emitted as SQL literals. Strings are wrapped in single quotes with any embedded quote doubled (O'Neil becomes 'O''Neil'). null becomes the keyword NULL, not the string.
Nested values
An array or nested object has no flat SQL column type, so it is serialized to a JSON string and quoted — ready for a json/jsonb column. The table name defaults to mytable; rename it after copying.
FAQ
What is the table name?
The generated statements use mytable as a placeholder. Replace it with your real table name after copying — a single find-and-replace covers every line.
How are apostrophes in strings handled?
Single quotes inside string values are doubled, which is the standard SQL escaping, so a name like O'Neil becomes 'O''Neil' and the statement stays valid.
What happens to nested objects and arrays?
They are serialized to a JSON string and quoted, which suits a json or jsonb column. Flatten your JSON first if you want separate scalar columns.
Do rows with different keys still work?
Yes. The column list is the union of all keys, and any object missing a key gets NULL in that position, so mismatched rows stay aligned.