JSON to SQL Converter
Convert a JSON array of records into SQL INSERT statements, with an optional CREATE TABLE. Nested objects are flattened into dot-separated column names so nothing is silently dropped.
The related converters are the CSV to SQL Converter and the SQL to CSV Converter, with the document form handled by the JSON to CSV Converter. To validate the source structure first, the JSON Validator reads it.
How to use the JSON to SQL
- 1 Paste the JSON array.
- 2 Set the table name and confirm the column mapping.
- 3 Choose the dialect and the batch size.
- 4 Copy the generated statements.
Getting JSON into a database
The shape of modern APIs is JSON, and the shape of relational storage is tables, so this conversion is a routine part of loading data. The work is in mapping an arbitrary object shape onto a fixed schema.
The cases that need thought are the ones where JSON is more expressive than the table: arrays, nested objects and absent fields. Each needs a decision about whether to discard the information, store it in a JSON column, or restructure the schema — and that decision is a data-modelling question, not a conversion setting.
- Name the columns explicitly in every insert.
- JSON null becomes the SQL null keyword, unquoted.
- Nested objects require flattening or a JSON column.
- Arrays cannot be stored in a scalar column without serialising.
Frequently asked questions
How is a nested object handled?
By flattening or by serialising, and the choice is significant. Flattening into separate columns requires the table to have those columns. Serialising into a JSON column works only where the database supports a JSON type. Neither is universally right, and the input's structure determines which is viable.
Why are my generated statements rejected?
Usually a type mismatch or an unsupported value. A JSON boolean needs conversion to the database's boolean representation, and a null in JSON has to become the SQL null keyword unquoted. Databases differ in how they handle these, which is why the dialect matters.
Should the insert specify columns explicitly?
Yes. An insert that relies on positional order breaks silently when the table definition changes, because the values land in the wrong columns. Naming the columns makes the statement self-describing and turns a schema change into a visible error rather than corrupt data.
Related Developer Tools
You might also need
Tools from other categories that people pair with the JSON to SQL: