JSON to SQL
Generate INSERT statements from a JSON array of objects. Column names are derived from the union of all keys, and values are quoted safely.
json rows0 ln / 0 ch
sql
readyunion of keys across rows / NULL, TRUE and FALSE handled
local / nothing uploadedAbout this tool
Generate INSERT statements from a JSON array. The column list is the union of all keys, so rows with different shapes still produce valid SQL, and values are escaped so an apostrophe cannot break the statement.
How to use it
- Paste an array of objects.
- Set the target table name.
- Press Convert.
- Copy the statement into your database client.
Examples
Two rows
[{"id":1,"name":"Ada"},{"id":2,"name":"Grace"}]INSERT INTO "users" ("id", "name")
VALUES
(1, 'Ada'),
(2, 'Grace');Limits and notes
- Identifiers are double quoted, which suits PostgreSQL and SQLite. MySQL default mode uses backticks.
- Very large arrays produce very large statements; batch them.
Frequently asked questions
- How is a single quote handled?
- It is doubled, which is the SQL standard escape. O Brien becomes O Brien with two quotes in the statement.
- What about nested objects?
- They are serialised to a JSON string and inserted as text. Flatten them first if you need real columns.
- Is this safe for untrusted input?
- For fixtures, yes. For application data at runtime, use parameterised queries instead of building SQL as text.
- How are booleans stored?
- As TRUE and FALSE, which an integer column will accept in MySQL.
Want the details? Read the full guide: Loading JSON Into a Database Without Quote Bugs.
Related Tools
CSV to JSONConvert CSV data to a JSON array of objects. Automatically maps the first row to object keys, perfect for importing spreadsheet data into web applications or APIs.
JSON to CSVConvert a JSON array into a clean CSV file. Extract unique keys to form the header row, perfect for exporting API data for analysis in Excel or Google Sheets.
XML to JSONConvert XML documents to JSON objects. Bridge the gap between legacy SOAP APIs and modern frontend applications while preserving attributes and hierarchical data.
JSON to XMLConvert JSON objects to valid XML markup. Automatically handle arrays, attributes, and special characters, making it easy to integrate with older enterprise systems.
YAML to JSONConvert YAML configuration into JSON, or JSON back into clean YAML. Parse errors report the line and column so you can fix the file quickly.
JSON to YAMLTurn a JSON object into readable, correctly indented YAML. Handy for turning API responses into Kubernetes manifests, Docker Compose files or CI config.
SQL to JSONTurn INSERT statements into JSON rows, or generate INSERT statements from a JSON array. Handles escaped quotes, NULL, booleans and a union of keys across rows.
JSON ValidatorValidate JSON syntax with detailed error messages. Catch trailing commas, missing brackets, and syntax errors instantly before sending payloads to your API.