Paste a JSON array and get a CREATE TABLE statement and INSERT rows for PostgreSQL, MySQL, SQLite or SQL Server.
Paste a JSON array of objects, upload a .json file or drop one here.
Updates as you type. Copy it or download a .sql file.
Converting…
This free JSON to SQL converter turns a JSON array into a CREATE TABLE statement and ready-to-run INSERT statements. Paste an API response, a database export or test data, choose PostgreSQL, MySQL, SQLite or SQL Server, and the script appears as you type. Nothing is uploaded: the conversion runs in your browser, so it is safe to use with real records.
It is built for the everyday jobs that come up when data starts life as JSON: loading an API dump into a local database, seeding a development or CI database, or moving a document export into a relational table. If you only need to see the shape of your data, the column types in the generated CREATE TABLE show how the converter read each field.
.json file. You can also drag a file onto the editor.users or public.users, and choose the Dialect that matches your database.data.sql, then run it in psql, the MySQL client, the sqlite3 shell or SQL Server Management Studio.This JSON to SQL table example uses the PostgreSQL dialect and a table named products. The third object has no active, created or tags keys, so those columns get NULL in that row. The apostrophe in O'Brien is doubled so the string stays valid.
[
{ "id": 1, "name": "Ada", "active": true, "price": 19.99, "created": "2025-01-20", "tags": ["a", "b"] },
{ "id": 2, "name": "O'Brien", "active": false, "price": 5, "created": "2025-02-03", "tags": [] },
{ "id": 3, "name": "Grace", "price": null }
]CREATE TABLE "products" (
"id" INTEGER,
"name" TEXT,
"active" BOOLEAN,
"price" DOUBLE PRECISION,
"created" DATE,
"tags" JSONB
);
INSERT INTO "products" ("id", "name", "active", "price", "created", "tags") VALUES
(1, 'Ada', TRUE, 19.99, '2025-01-20', '["a","b"]'),
(2, 'O''Brien', FALSE, 5, '2025-02-03', '[]'),
(3, 'Grace', NULL, NULL, NULL, NULL);The converter collects every key that appears in any object, in the order it first appears, and makes each one a column. It then looks at all the values in that column to decide the type. The table shows what each JSON value becomes in the four dialects.
| JSON value | PostgreSQL | MySQL | SQLite | SQL Server |
|---|---|---|---|---|
| Whole number | INTEGER | INT | INTEGER | INT |
| Whole number above 2,147,483,647 | BIGINT | BIGINT | INTEGER | BIGINT |
| Decimal number | DOUBLE PRECISION | DOUBLE | REAL | FLOAT |
true / false | BOOLEAN, TRUE/FALSE | BOOLEAN, TRUE/FALSE | INTEGER, 1/0 | BIT, 1/0 |
| Short string (255 characters or fewer) | TEXT | VARCHAR(255) | TEXT | NVARCHAR(255) |
| Longer string | TEXT | TEXT or LONGTEXT | TEXT | NVARCHAR(4000) or NVARCHAR(MAX) |
| Date such as 2025-01-20 | DATE | DATE | TEXT | DATE |
| ISO 8601 timestamp | TIMESTAMP or TIMESTAMPTZ | DATETIME (UTC) | TEXT | DATETIME2 or DATETIMEOFFSET |
| Object or array | JSONB | JSON | TEXT | NVARCHAR(MAX) |
null or missing key | NULL | NULL | NULL | NULL |
A column is only typed as a number if every non-null value in it is a number. Whole numbers mixed with decimals become a floating-point column, and a date mixed with a timestamp becomes a timestamp. Any other mix, such as 1 in one row and "two" in the next, becomes a text column, and the values are stored as their text. A column that is null in every row has no evidence to go on, so it becomes text.
Every column is nullable, and no primary key or index is added, because a sample of JSON cannot tell which fields are unique. Add a PRIMARY KEY or NOT NULL yourself once you have checked the data. Decimals use floating-point types, so change a price column to NUMERIC or DECIMAL if you need exact arithmetic. Also remember that JavaScript reads numbers as 64-bit floats, so integers larger than 9,007,199,254,740,991 lose precision and are typed as floating point.
Relational tables are flat, so a nested object or array is written as JSON text into one column. In PostgreSQL and MySQL that is a real JSONB or JSON column you can query with ->> or JSON_EXTRACT. SQLite and SQL Server have no separate JSON type, so the column is text, but json_extract and JSON_VALUE work on it. If you want a child table instead, take the nested array out of the document and convert it as its own input.
JSON has no date type, so the converter recognizes ISO 8601 strings: 2025-01-20 and 2025-01-20T08:30:00Z, with optional fractional seconds and a Z or offset. Impossible dates such as February 30 stay plain strings. PostgreSQL uses TIMESTAMPTZ and SQL Server uses DATETIMEOFFSET when any value in the column has a zone. MySQL's DATETIME has no zone, so values with an offset are converted to UTC. SQLite has no date type, so dates stay as ISO text, which sorts and compares correctly.
Single quotes inside values are doubled, and column and table names are always quoted, with the quote character escaped, so odd keys such as first name work. MySQL also treats a backslash as an escape character in strings, so backslashes are doubled for that dialect. SQL Server text gets the N prefix so non-ASCII characters survive. Rows are grouped into INSERT statements of up to 500 rows, which stays under SQL Server's limit of 1,000 rows per statement. A dotted table name such as public.users is split into schema and table.
The best input is an array of objects. A single object becomes one row. If an object contains an array of objects, such as { "users": [ ... ] }, the first such array is used as the rows, which suits most API responses. If you really want the outer object as a row, wrap it in square brackets.
Seeding is the most common reason, and our guide to seeding test databases in CI/CD covers how to do it reliably. You can create realistic rows with the JSON Generator and paste them straight into this converter. For bulk loads and spreadsheets, try the JSON to CSV converter or the JSON to Excel converter. To describe the same data as types in code, use JSON to TypeScript, or build a JSON Schema to validate the data before you load it.
Paste a JSON array of objects into the JSON Input editor, or upload a .json file. Pick your database, set a table name, and the CREATE TABLE and INSERT statements appear as you type. Copy them, or click Download to save data.sql.
It reads every row, not just the first. Whole numbers become INTEGER or BIGINT, other numbers a floating-point type, true/false a boolean type, ISO 8601 strings a DATE or timestamp type, and nested objects and arrays a JSON type. A column that mixes types falls back to text.
Yes. The Dialect option switches identifier quoting, boolean literals and column types between PostgreSQL, MySQL, SQLite and SQL Server. For example, nested JSON becomes JSONB in PostgreSQL, JSON in MySQL, and text in SQLite and SQL Server.
Each nested object or array is written as JSON text into a single column, using JSONB on PostgreSQL and JSON on MySQL. The converter does not split nested data into child tables, so you can query it with your database's JSON functions or convert the nested array on its own.
An array of objects is the standard input, with one row per object. A single object becomes one row, and if an object holds an array of objects, such as {"users": [...]}, that array is used as the rows. Wrap an object in [ ] to force it to be treated as a single row.
Single quotes in values are doubled and identifiers are quoted, so values and key names cannot break out of their string or name. It is meant for seeding and importing data. In application code, use parameterized queries instead of building SQL strings.
No. The conversion runs entirely in your browser with JavaScript, so your data never leaves your device. That makes it fine to use with exports that contain customer or internal records.