Convert JSON to SQL INSERT Statements
Generate SQL INSERT statements from a JSON array of objects. Handles nested values, missing fields, and configurable table names.
JSON → SQL
Free JSON to SQL converter. Convert a JSON array of objects to SQL INSERT statements. Handles missing fields, nested objects, booleans, and nulls. Works in your browser.
Output will appear here
How to use the JSON → SQL
Paste or upload your JSON data
Paste text directly into the input box, drag and drop a file onto it, or click "Upload file" to browse. Conversion starts instantly on paste — no button click required.
Configure options (optional)
Open the Options panel to customise delimiter, headers, nested-object flattening, and more. Use the Field Selector to pick exactly which columns appear in the output.
Copy or download your SQL
Click Copy to grab the result, or Download to save the file. Everything runs locally in your browser — no data ever leaves your device.
Frequently Asked Questions
- Is my data safe?
- Yes. Every conversion runs entirely inside your browser. No data is ever transmitted to a server. The tool works offline once loaded.
- What is the maximum file size?
- There is no hard limit. Files under 1 MB convert instantly. Files 1–10 MB show a progress indicator. Files over 10 MB prompt a warning and run in a background thread to keep the browser responsive.
- Why does my JSON fail to parse?
- Common causes are trailing commas, single-quoted strings, unquoted keys, or missing closing brackets. The converter auto-repairs many of these and tells you exactly what it changed.
- Can I convert multiple files at once?
- The tool handles one file at a time. For bulk conversion, consider the csvjson CLI or API.
Related Converters
How it works
Union of all keys across all records
JSON records can have different fields. The converter collects every key across the entire array and uses the full set as the column list. Missing fields in individual records become NULL.
Type-aware value escaping
JSON booleans become 1/0. JSON null becomes SQL NULL. Numbers stay unquoted. Strings are single-quoted. Nested objects and arrays are serialized as JSON strings in the cell value.
Example
Stripe payment events imported into a payments table
[
{ "id": "pi_3Mtw", "amount": 2000, "currency": "usd", "status": "succeeded" },
{ "id": "pi_4Xbc", "amount": 500, "currency": "eur", "status": "failed", "error": "card_declined" }
]INSERT INTO `my_table` (`id`, `amount`, `currency`, `status`, `error`) VALUES
('pi_3Mtw', 2000, 'usd', 'succeeded', NULL);
INSERT INTO `my_table` (`id`, `amount`, `currency`, `status`, `error`) VALUES
('pi_4Xbc', 500, 'eur', 'failed', 'card_declined');The 'error' field is absent in record 1 — it becomes NULL. Record 2 has all 5 fields.
Edge cases, handled
Inconsistent fields across records
Different records having different keys is handled automatically. The column list is the union of all keys. Missing values become NULL.
Nested objects and arrays
Nested values are serialized as JSON strings: '{"city":"NYC"}'. If you need nested fields as separate columns, flatten the JSON first.
Booleans
JSON true becomes 1 and false becomes 0. This is the standard SQL representation of boolean values compatible with MySQL, PostgreSQL, and SQLite.
Frequently asked questions
My JSON has nested objects. Will the SQL output capture that data?
Yes, but as a JSON string in the column value rather than separate columns. For example, a 'customer' field containing {"id": 1, "name": "Alice"} becomes the string '{"id":1,"name":"Alice"}'. Flatten the JSON first if you need each nested field as its own column.
How are JSON booleans handled in SQL?
JSON true becomes 1 and JSON false becomes 0. This is compatible with TINYINT(1) in MySQL (commonly used for boolean columns), BOOLEAN in PostgreSQL, and INTEGER in SQLite.
Can I set the table name?
Yes. The table name field in the options panel sets the INSERT INTO target. The default is 'my_table'. The name is backtick-quoted to handle spaces and reserved words.
What's the difference between CSV to SQL and JSON to SQL?
The main practical difference: JSON preserves types (numbers stay numbers, booleans become 1/0, nulls become NULL) while CSV treats everything as strings by default. Use JSON-to-SQL when your source data has typed values you want to preserve in the database.
Related Tools
All conversions run in your browser — nothing is uploaded.
Browse all 26 converters →