JSON to SQL Converter
Convert JSON arrays/objects into SQL INSERT statements instantly
From a JSON array to ready-to-run INSERT statements
APIs and exports hand you JSON, but databases want rows. Loading a list of records usually means writing a script or hand-editing dozens of INSERT lines. JSON to SQL does the mechanical part: it reads an array of objects, treats each object as a row and each key as a column, and prints one INSERT statement per record for the table name you supply.
Converting your data
- Type your table name into Target Table Name. It starts as my_table.
- Paste your JSON into the Source JSON (Array of Objects) box using the Paste button, or click Sample to see an example. Clear resets the box.
- Click Generate SQL INSERT Statements.
- Use Copy Script in the SQL Script Output panel to grab the result.
The script begins with a comment line noting how many records were found, followed by one statement for each object, such as INSERT INTO users (`id`, `name`) VALUES (1, 'Jane');
How values are written
- Strings are wrapped in single quotes, and any single quote inside the text is doubled so the statement stays valid.
- Null values become NULL.
- Numbers and booleans are written as they appear, without quotes.
- If you paste a single object instead of an array, it is treated as a one-row list.
Where you would use it
- Seeding a development database with sample records copied from an API response.
- Moving a small export from a document store into a relational table.
- Building test fixtures for a bug report.
- Turning a settings list into a quick data migration script.
Limits to keep in mind
Column names come from the keys of the first object only, and the same keys are used for every row. If later records have extra fields, those fields are ignored, and if they are missing a key the statement will contain the text undefined, so make your objects consistent first. Column names are wrapped in backticks, which suits MySQL and MariaDB; PostgreSQL and SQL Server users will need to replace them with double quotes or square brackets. Nested objects and arrays are not converted into JSON columns, so flatten them beforehand. The table name is used as typed, without quoting, and the tool creates no CREATE TABLE statement, so the table must already exist. Invalid JSON produces an error message instead of output. Review the script before running it against any live database. Conversion takes place in your browser.
Related Tools