About the JSON to SQL Insert Generator
Seeding a table from an API response or a fixture file is a common chore. This generator takes a JSON array of objects, flattens nested objects into dotted column names, infers a column type from the values (INTEGER, DECIMAL, BOOLEAN or a sized VARCHAR), and writes a CREATE TABLE followed by a multi-row INSERT. Keys that differ between objects are unioned into the column list, with missing values inserted as NULL.
Identifier quoting is selectable: double quotes for PostgreSQL and SQLite, backticks for MySQL and MariaDB, or none if your names are simple. String values have single quotes doubled, booleans become TRUE and FALSE, and nested arrays that were not flattened are inserted as JSON text.
Review the inferred types before running the script; a column that happens to contain only integers in the sample may need to be wider in production. The reverse converter parses INSERT statements back into JSON, and CSV to SQL does the same job for spreadsheet data.
How to use
- Paste a JSON array of objects and set the table name.
- Choose identifier quotes for your database.
- Copy the SQL, check the inferred types, and run it.
Common questions
- What happens to nested objects?
- They are flattened into dotted column names, which are converted to underscores for the SQL identifiers.
- Does it batch large inserts?
- All rows go in one multi-row INSERT. Split the JSON if your database limits rows per statement.
- Are dates typed as DATE?
- No. ISO date strings are inserted as text into a VARCHAR column; change the type to DATE or TIMESTAMP in the CREATE TABLE.