JSON to SQL Insert
Convert a JSON array of objects into SQL INSERT statements online for MySQL, PostgreSQL or SQLite. Seed databases and test fixtures in seconds.
Runs in your browser · Nothing uploadedFree · No sign-up
Something not working, or missing a feature? Send feedback
About the JSON to SQL Insert
The JSON to SQL Insert converter turns a JSON array of objects into INSERT statements for MySQL, PostgreSQL or SQLite, quoting identifiers and escaping values for the dialect you choose.
Conversion happens in your browser, so your files and records stay private.
How to use the JSON to SQL Insert
- Paste a JSON array of objects.
- Set the table name and dialect, and choose one multi-row INSERT or one per row.
- Copy the SQL and run it against your database.
Example
Input
[
{ "id": 1, "email": "[email protected]", "name": "Ada O'Neil", "active": true, "meta": { "plan": "pro" } },
{ "id": 2, "email": "[email protected]", "name": "Grace", "active": false, "meta": null }
]Result
INSERT INTO `users` (`id`, `email`, `name`, `active`, `meta`) VALUES (1, '[email protected]', 'Ada O''Neil', 1, '{"plan":"pro"}'), (2, '[email protected]', 'Grace', 0, NULL);
MySQL dialect: identifiers in backticks, the apostrophe in O’Neil escaped, booleans as 1 and 0, and the meta object stored as JSON text.
Common mistakes
- Rows with different keys. Columns come from all objects, and missing values are inserted as NULL. Make sure those columns allow NULL or have a default.
- Very large inserts. One multi-row INSERT can exceed max_allowed_packet in MySQL. Use one INSERT per row, or split the data, for many thousands of rows.
- Running generated SQL on production. The values are escaped, but review the statements and test on a copy first, especially the table name and the dialect.
Works well with the JSON to SQL Insert
- CSV to JSON: start from a spreadsheet export.
- SQL Formatter: format the INSERT statements for review.
- Large CSV Generator: generate realistic test data.
Frequently asked questions
Are values escaped safely?
Yes. Strings are quoted and escaped for the selected dialect, and identifiers are quoted. Still review generated SQL before running it on production data.
How are nested objects stored?
Objects and arrays are written as JSON text, which suits JSON or TEXT columns.
Does it create the table?
No. It writes INSERT statements for an existing table, so you keep control of column types and indexes.
How are booleans written in PostgreSQL?
As TRUE and FALSE. MySQL and SQLite have no real boolean type, so they get 1 and 0.
Guides and tutorials
Related tools
JSON to CSV
Convert JSON arrays to CSV online with automatic column detection, nested object flattening and custom delimiters. Open the result in Excel or Sheets.
CSV to JSON
Convert CSV to a JSON array online with header detection, type inference and delimiter auto-detection. Turn spreadsheet exports into data for APIs and code.
JSON to XML
Convert JSON to well-formed XML online with a configurable root element and attribute support. Validate the input and download the XML file.
XML to JSON
Convert XML to JSON online, keeping attributes and turning repeated elements into arrays. Malformed XML is reported with its location.
JSON to YAML
Convert JSON to clean, human-readable YAML online. Turn API responses and package files into config for Kubernetes, Docker Compose or CI pipelines.
YAML to JSON
Convert YAML documents to formatted JSON online with syntax validation. Errors are reported by line, so broken indentation is quick to find and fix.