JSON to SQL Converter
Turn JSON records into a ready-to-run table and INSERT statements.
How to use the JSON to SQL Converter
- Paste a JSON array of objects, or open a .json file.
- Choose your database and, optionally, a table name.
- Check the inferred column types in the CREATE TABLE statement.
- Copy the SQL or save it as a .sql file and run it in your database tool.
Examples
About this tool
Data often arrives as JSON, from an API, an export or a script, while the place you need it is a database table. This converter writes the SQL for you: a CREATE TABLE statement whose columns come from the keys of your objects, and INSERT statements for every record, batched so large files load efficiently.
Column types are worked out from the values themselves. Whole numbers become INTEGER (or BIGINT when they are large), numbers with decimals become a floating-point type, true and false become BOOLEAN or 0 and 1 depending on the database, and strings that look like dates or timestamps get date types. A column that ever holds null is left nullable, and keys missing from some records simply insert NULL.
Nested objects can be spread into separate columns, so address.city becomes address_city, or kept whole in a JSON column for databases that support it. Quotes and backslashes in your text are escaped correctly for the chosen database, which avoids the broken statements that string concatenation tends to produce.
Frequently asked questions
What JSON shapes are accepted?
An array of objects is ideal. A single object becomes one row, and an object that wraps a single array, such as {"orders": [...]}, uses that array and names the table after the key.
How are column types decided?
Every value in a column is checked and the narrowest type that fits them all is chosen. If values disagree, for example numbers and words, the column falls back to text so nothing is lost.
Is the output safe from SQL injection?
Values are escaped according to each database's rules, so quotes inside the data cannot break out of the statement. Still review generated SQL before running it on a production database.
Why does SQL Server use N'...' for some values?
The N prefix tells SQL Server the text is Unicode, so accented letters and other scripts are stored correctly. It is only added where the text needs it.
Is my JSON uploaded?
No. The conversion runs entirely in this page, so customer records, keys and other private data never leave your device.