JSON to SQL Table Converter
Infer a SQL Server CREATE TABLE statement from a JSON object, with column types based on the values in your sample.
Input JSON
Paste your JSON or upload a JSON file.
Generated Output
Your converted code will appear here.
About the JSON to SQL Table Converter
Infer a SQL Server CREATE TABLE statement from a JSON object, with column types based on the values in your sample.
When you need to store API data or import a JSON file into a relational database, the first step is a table whose columns match the JSON keys. This tool reads a JSON object, or the first object of an array, and generates a CREATE TABLE statement in SQL Server (T-SQL) syntax. It picks a column type for each key from the type of its value.
How to use it
- Paste a JSON sample into the input editor or upload a
.jsonfile. - Select Convert.
- Review the output, then copy it or download it.
How JSON types are mapped
| JSON value | Generated as |
|---|---|
| string | NVARCHAR(255) |
| whole number (42) | INT |
| decimal number (9.99) | DECIMAL(18,2) |
| true / false | BIT |
| nested object or array | NVARCHAR(MAX) (store as JSON text) |
| null | NVARCHAR(MAX) |
Example
This input:
{
"id": 1,
"name": "Ada",
"price": 9.99,
"active": true,
"tags": ["new", "sale"],
"address": { "city": "London", "zip": "N1" }
}
produces this output:
CREATE TABLE MyTable (
id INT,
name NVARCHAR(255),
price DECIMAL(18,2),
active BIT,
tags NVARCHAR(MAX),
address NVARCHAR(MAX)
);
Limitations and things to review
Before running the script against a real database:
- Rename MyTable to your table name and add a PRIMARY KEY (for example id INT NOT NULL PRIMARY KEY).
- All columns are nullable. Add NOT NULL where your data requires a value.
- Nested objects and arrays become NVARCHAR(MAX) columns. For relational data, normalize them into separate tables with foreign keys instead.
- Strings default to NVARCHAR(255). Widen the column for long text, or narrow it for codes and IDs.
- The output only creates the table. It doesn't include INSERT statements for the data.
- The syntax targets SQL Server. For MySQL or PostgreSQL, change BIT to BOOLEAN and NVARCHAR to VARCHAR or TEXT.
Frequently Asked Questions
The column types (NVARCHAR, BIT, DECIMAL(18,2)) are SQL Server / Azure SQL syntax. Other databases use different names, for example BOOLEAN and VARCHAR or TEXT in PostgreSQL and MySQL, so adjust the types before running the script there.
Yes. SQL Server 2016 and later provide JSON_VALUE, JSON_QUERY and OPENJSON, which read values from JSON stored as text. That is a practical option for nested data you rarely filter on.
No. The conversion runs in your browser with JavaScript, and your JSON isn't sent to or stored on DevToolsWorld servers.
The converter shows the parser's error message instead of output. Use the JSON Formatter to validate and fix the document, then convert it again.
Yes. It's free and doesn't require an account or any installation.