JSON to SQL
Generate SQL CREATE TABLE and INSERT scripts from your JSON data.
About the JSON to SQL generator
The TConverter JSON to SQL tool reads JSON data and writes a ready-to-run SQL script for it: a CREATE TABLE statement that describes the columns, followed by one INSERT INTO statement per record. You choose the table name, paste your JSON, and click Generate SQL. The script appears below, where you can copy it or download it as a .sql file. The tool is free and requires no sign-up.
This is useful whenever data arrives as JSON but needs to live in a relational database: loading an API export into a staging table, seeding a development or test database, moving records out of a document store, or quickly creating sample data for a demo. Writing column definitions and dozens of INSERT statements by hand is tedious, and this tool removes most of that work.
The generated script uses Microsoft SQL Server (T-SQL) syntax. Table and column names are wrapped in square brackets, text values are written as Unicode N'...' literals with single quotes escaped, and batches are separated with GO. Column types are inferred from the values: whole numbers become INT, decimals FLOAT, booleans BIT, strings that start with a YYYY-MM-DD date become DATETIME, and other text becomes NVARCHAR(MAX). If the records contain an id field, it is used as the PRIMARY KEY; otherwise an Id INT IDENTITY(1,1) PRIMARY KEY column is added automatically.
Nested data is handled relationally rather than dumped as text. A nested object such as address is flattened into columns like address_city. A list of simple values is stored as a JSON string in an NVARCHAR(MAX) column. A list of objects, such as the order lines of an order, becomes a separate child table with its own CREATE TABLE and INSERT statements, a foreign key column pointing to the parent row and a FOREIGN KEY constraint. This works recursively, so deeper lists produce further child tables.
Everything is generated in your browser; the JSON is not sent to a server. Please review the script before running it. Types are guessed from the data, so you may want to adjust lengths or types for production use. When the parent records have no id field, child rows refer to parents by their position in the input, which matches the identity values only if the parent table starts empty. Characters other than letters, digits and underscores in the table name are replaced with underscores.
Frequently asked questions
Which SQL dialect does the generator produce?
The script is written for Microsoft SQL Server (T-SQL): square-bracket identifiers, NVARCHAR(MAX), BIT, IDENTITY(1,1) and GO batch separators. Other databases may need small syntax changes.
How are column types chosen?
Types are inferred from the JSON values: INT for whole numbers, FLOAT for decimals, BIT for true/false, DATETIME for strings starting with a YYYY-MM-DD date, and NVARCHAR(MAX) for other text and null values.
What happens to nested arrays of objects?
Each one becomes a separate child table with a foreign key column and a FOREIGN KEY constraint that references the parent table. Nested lists inside those objects create further child tables.
Do I need an id field in my JSON?
No. If an id field exists it becomes the primary key; otherwise an auto-incrementing Id IDENTITY column is added to the table.
Is my JSON uploaded anywhere?
No. The SQL script is generated entirely in your browser, and the tool is free to use without an account.