Paste a JSON array of objects and get a CREATE TABLE statement with inferred column types plus INSERT statements for MySQL, PostgreSQL, SQLite or SQL Server. Nested objects can be stored as JSON columns or flattened into separate columns.
Last updated:
Converts automatically as you type. Nothing is uploaded.
Detected columns
#
Column
SQL type
Nulls / missing
Example
Advertisement
Advertisement
How to use the JSON to SQL Converter
Paste your JSON (an array of objects), upload a .json file, or click Sample.
Choose the SQL dialect and type the table name.
Decide how to handle nested data: keep it as a JSON column or flatten it into separate columns.
Set the options: rows per INSERT, CREATE/DROP TABLE, primary key, NOT NULL and transaction.
Copy or download the .sql file and run it in your database client.
Type mapping by dialect
JSON values in the column
MySQL
PostgreSQL
SQLite
SQL Server
Whole numbers (42)
INT
INTEGER
INTEGER
INT
Whole numbers above 2,147,483,647
BIGINT
BIGINT
INTEGER
BIGINT
Decimals (1250.5)
DECIMAL(p,s)
NUMERIC(p,s)
REAL
DECIMAL(p,s)
true / false
BOOLEAN
BOOLEAN
INTEGER (1/0)
BIT (1/0)
"2024-01-15"
DATE
DATE
TEXT
DATE
"2024-01-15T09:30:00"
DATETIME
TIMESTAMP
TEXT
DATETIME2
"2024-01-15T09:30:00Z"
VARCHAR(35)
TIMESTAMPTZ
TEXT
DATETIMEOFFSET
Strings up to 255 characters
VARCHAR(n)
VARCHAR(n)
TEXT
NVARCHAR(n)
Longer strings
TEXT
TEXT
TEXT
NVARCHAR(MAX)
Objects and arrays
JSON
JSONB
TEXT
NVARCHAR(MAX)
A column containing values of different JSON types (for example numbers in some rows and strings in others) falls back to VARCHAR or TEXT so every value fits. null and missing keys always become SQL NULL. VARCHAR lengths are rounded up to 10, 20, 50, 100, 150 or 255 characters to leave a little room for longer values later.
Example
The JSON [{"id":1,"name":"Ann","tags":["a"]},{"id":2,"name":"O'Brien"}] with the PostgreSQL dialect produces:
JSON column keeps the original structure and suits data you mostly read back as a whole. PostgreSQL JSONB and MySQL JSON can still be queried with operators such as ->> and JSON_EXTRACT().
Flatten turns nested objects into ordinary columns (address_city, address_zip), which is easier to index, filter and join. Arrays are still stored as JSON text because they can hold any number of items; for real one-to-many data, move them to a separate table.
For millions of records, a bulk loader is faster than INSERT statements: PostgreSQL can load JSON lines with COPY, MySQL with LOAD DATA, and SQL Server can read JSON directly with OPENJSON.
Frequently asked questions
What JSON structure does the converter expect?
An array of objects, where each object is one row and each key is a column, for example [{"id":1,"name":"Ann"},{"id":2,"name":"Bo"}]. A single object becomes one row, and if the array sits inside a wrapper object such as {"data":[...]} or {"results":[...]}, the first array of objects is used automatically.
How are column types chosen?
Each column's values are inspected across all rows. Whole numbers become INT, or BIGINT above 2,147,483,647; numbers with decimals become DECIMAL(p,s) sized to fit; true/false becomes BOOLEAN (BIT in SQL Server, INTEGER in SQLite); strings shaped like YYYY-MM-DD or a date-time become DATE or DATETIME/TIMESTAMP; other strings become VARCHAR sized to the longest value, or TEXT if longer than 255 characters.
What happens to nested objects and arrays?
By default they are stored as JSON text in a JSON-typed column: JSON in MySQL, JSONB in PostgreSQL, NVARCHAR(MAX) in SQL Server and TEXT in SQLite. Choose Flatten to turn {"address":{"city":"Oslo"}} into a column named address_city instead; arrays are still stored as JSON.
What if objects have different keys?
The converter collects the union of all keys in the order they first appear. When an object lacks a key, NULL is inserted for that column.
How are quotes and special characters escaped?
Strings are wrapped in single quotes with embedded single quotes doubled ('O''Brien'), which is standard SQL. MySQL output also escapes backslashes, and SQL Server strings use the N'...' prefix to preserve Unicode.
Are very large numbers kept exactly?
JSON numbers are read as JavaScript double-precision values, which are exact up to 9,007,199,254,740,991. Larger integers, such as some 64-bit IDs, should be stored as strings in your JSON to keep every digit.
Is my JSON sent to a server?
No. Parsing and SQL generation run entirely in your browser, so your data never leaves your device.
Are all the tools on FreeToolCabin tested for quality and accuracy?
Yes! Every tool on our site undergoes automated Q/A testing in real browser environments to ensure high precision, correct output, and zero errors. If you happen to spot a bug or have a suggestion, please contact us at [email protected] and our team will review it right away.