JSON to SQL Converter
Turn a JSON array into CREATE TABLE and INSERT statements for MySQL, PostgreSQL, SQLite or SQL Server. Column types are inferred from your data, text is escaped for the database you pick, and everything runs in your browser.
JSON input
SQL output
Paste a JSON array of objects to get SQL.
Options
How to convert JSON to SQL
- Add your JSON. Paste an array of objects, where each object becomes one row, or drop a .json file. A single object gives one row. Press Load sample to see an example.
- Choose the database and table. Pick MySQL, PostgreSQL, SQLite or SQL Server and type the table name. Identifiers are quoted the way that database expects.
- Copy or download. Copy the SQL or save it as a .sql file, then run it in your database client. Try it on a test database first.
There is no convert button. The SQL updates whenever the input or an option changes.
Before
[{"id": 1, "name": "Ava", "paid": true},
{"id": 2, "name": "Ben O'Neil", "paid": false}]After
CREATE TABLE `my_table` (
`id` INT,
`name` VARCHAR(255),
`paid` TINYINT(1)
);
INSERT INTO `my_table` (`id`, `name`, `paid`) VALUES
(1, 'Ava', TRUE),
(2, 'Ben O''Neil', FALSE);How column types are chosen
The converter reads every row before it decides on a type, so one unusual value changes the whole column. A column that holds whole numbers in every row becomes an integer, one row with 1.5 makes it a decimal type, and a column that mixes text and numbers becomes text with the numbers quoted.
| JSON value | MySQL | PostgreSQL | SQLite | SQL Server |
|---|---|---|---|---|
| Whole number (fits in 32 bits) | INT | INTEGER | INTEGER | INT |
| Larger whole number (up to 64 bits) | BIGINT | BIGINT | INTEGER | BIGINT |
| Whole number beyond 64 bits | DECIMAL(65,0) | NUMERIC(38,0) | NUMERIC | NUMERIC(38,0) |
| Decimal number | DECIMAL(p,s) or DOUBLE | NUMERIC(p,s) or DOUBLE PRECISION | NUMERIC(p,s) or REAL | DECIMAL(p,s) or FLOAT |
| true or false | TINYINT(1) | BOOLEAN | INTEGER (1 or 0) | BIT (1 or 0) |
| Date such as "2026-03-14" | DATE | DATE | TEXT | DATE |
| Timestamp such as "2026-03-14T09:30:00Z" | DATETIME | TIMESTAMP or TIMESTAMPTZ | TEXT | DATETIME2 |
| Text | VARCHAR(255) or TEXT | TEXT | TEXT | NVARCHAR(255), (4000) or (MAX) |
| Nested object or array kept as JSON | JSON | JSONB | TEXT | NVARCHAR(MAX) |
A null becomes NULL in the row and does not affect the column type. A timestamp that carries an offset other than Z, such as +02:00, is kept as text for every database except PostgreSQL, because the others have no column type that stores it faithfully.
Review the result before you run it
The converter only knows the data you paste. It cannot know your primary key, which columns must be NOT NULL, what to index, or whether a VARCHAR(255) will be long enough for next month's data. Treat the CREATE TABLE statement as a starting point and add those yourself.
Text values are escaped for the database you chose: single quotes are doubled, and for MySQL backslashes are doubled too. That is right for loading data you have exported and trust. It is not a way to build queries from user input. In an application, use parameterized queries and let the database driver handle the values.
For very large data sets, a bulk loader is much faster than thousands of INSERT statements. Convert the JSON to CSV with the JSON to CSV converter and load it with COPY in PostgreSQL, LOAD DATA in MySQL or BULK INSERT in SQL Server.
What this converter does
- Private by design
- The JSON is converted in your browser tab. Your rows are never uploaded, so it is fine to use with real exports.
- Large numbers stay exact
- A 19-digit ID is written to the SQL with every digit. The converter reads numbers as text, so nothing is rounded on the way.
- Nested objects
- By default a nested object is flattened into columns joined with an underscore, such as address_city. Choose Store as JSON text to keep it in one column instead. Arrays are always stored as JSON text.
- Wrapped data is found
- If the JSON is an object with exactly one array of objects inside it, for example {"data": [...]}, that array is used and the status line says so.
- Batches
- Choose one row per statement, or 100, 500 or 1,000 rows per INSERT. SQL Server accepts at most 1,000 rows in one INSERT, so larger batches are capped there.
- Related tools
- Need a table for a spreadsheet instead? Use JSON to Excel. Tidy or check the JSON first in the JSON Formatter.
Frequently asked questions
How do I convert JSON to SQL INSERT statements?
Paste a JSON array of objects, choose your database and table name, and the CREATE TABLE and INSERT statements appear. Copy them or download a .sql file and run it in your database client.
Which databases does it support?
MySQL and MariaDB, PostgreSQL, SQLite and SQL Server. The choice changes how names are quoted, which column types are used and how text and booleans are written.
How does it choose column types?
It looks at the values in every row. A column that is whole numbers in every row is an integer, decimals make it a decimal or floating-point type, true and false give a boolean, ISO dates and timestamps give date types, and anything mixed or textual becomes text. Check the result and adjust it for your needs.
What happens to nested objects and arrays?
Nested objects are flattened into columns such as address_city by default, or stored as JSON text if you choose that. Arrays are stored as JSON text in a JSON column, or in a text column for databases with no JSON type.
How are quotes and special characters escaped?
Single quotes inside text are doubled, as the SQL standard requires. For MySQL, backslashes are doubled as well. If your MySQL server runs with the NO_BACKSLASH_ESCAPES mode, a doubled backslash would be stored as two characters, so switch that mode off or edit the output.
Does it create a primary key or indexes?
No. The tool only knows the data, so it does not guess keys, constraints or indexes. Add them to the CREATE TABLE statement before you run it.
How many rows can I convert?
Files up to a few megabytes work comfortably in the browser. For millions of rows, convert to CSV and use your database's bulk loader instead of INSERT statements.
Is my JSON uploaded to a server?
No. The conversion happens in your browser and nothing is sent anywhere.
What does the DECIMAL option do?
With it on, a column of decimal numbers such as 19.90 and 249.00 gets a DECIMAL type sized to the digits in your data, which avoids floating-point rounding for prices. With it off, a floating-point type is used instead.