Next-Gen App & Browser Testing Cloud
Trusted by 2 Mn+ QAs & Devs to accelerate their release cycles

Turn JSON arrays and nested objects into CREATE TABLE and INSERT statements for MySQL, PostgreSQL, SQLite, SQL Server, or Oracle, with column types inferred for you.
A JSON to SQL converter reads JSON data, the format defined by RFC 8259, and generates SQL that loads it into a relational database. This tool produces a CREATE TABLE statement with inferred column types plus the matching INSERT statements for every object.
It emits dialect-correct SQL for MySQL, PostgreSQL, SQLite, SQL Server, and Oracle, handling identifier quoting, type names, value escaping, and JSON storage per database. To go the other direction, use the SQL to JSON tool. Clean the result with the SQL Formatter, or validate the input first with JSON Validator.
The converter parses your JSON in the browser, infers a schema, and reassembles the data as SQL. It runs five steps in order.
JSON.parse reads the input. Arrays of objects pass through; a single object is wrapped into a one-row array.NULL.BOOLEAN, INTEGER, a decimal type, DATE, a timestamp type, or a sized VARCHAR that falls back to TEXT past 255 characters.TRUE / FALSE for PostgreSQL or 1 / 0 elsewhere.All processing happens in your browser. No data is uploaded, so the records in your JSON never leave your device.
.json or .txt file, or press the sample button to load an example with nested objects and arrays.parent_child columns; Stringify stores them as JSON in a single column..sql file for your migration.| Dialect | Identifier quote | Integer PK auto-increment | JSON storage type |
|---|---|---|---|
| MySQL | `name` | AUTO_INCREMENT | JSON |
| PostgreSQL | "name" | SERIAL | JSONB |
| SQLite | "name" | INTEGER PRIMARY KEY AUTOINCREMENT | TEXT |
| SQL Server | [name] | IDENTITY(1,1) | NVARCHAR(MAX) |
| Oracle | "name" | GENERATED BY DEFAULT AS IDENTITY | CLOB |
Pick a strategy from the Nested JSON dropdown. Given the input { "id": 1, "address": { "city": "London", "zip": "NW1" }, "tags": ["a","b"] }, the two strategies produce:
id, address_city, address_zip, tags. Object paths are joined with underscores; arrays are stringified into a single column. Recursion is capped at depth 5.id, address, tags. The nested values are stored verbatim in the dialect's JSON storage type, so they remain queryable with JSON_EXTRACT, ->>, or OPENJSON.| JSON value | MySQL | PostgreSQL | SQLite | SQL Server | Oracle |
|---|---|---|---|---|---|
| Boolean | TINYINT(1) | BOOLEAN | INTEGER | BIT | NUMBER(1) |
| Integer number | INT | INTEGER | INTEGER | INT | NUMBER(10) |
| Decimal number | DOUBLE | DOUBLE PRECISION | REAL | FLOAT | NUMBER |
| String (YYYY-MM-DD) | DATE | DATE | TEXT | DATE | DATE |
| String (ISO timestamp) | DATETIME | TIMESTAMP | TEXT | DATETIME2 | TIMESTAMP |
| String (short) | VARCHAR(n) | VARCHAR(n) | TEXT | NVARCHAR(n) | VARCHAR2(n) |
| String (> 255) | TEXT | TEXT | TEXT | NVARCHAR(MAX) | CLOB |
| Object / array (Stringify mode) | JSON | JSONB | TEXT | NVARCHAR(MAX) | CLOB |
CREATE TABLE and INSERT output across dialects to see how each database differs.Related tools: the CSV to SQL and JSON to CSV converters, or generate SQL from a plain-English description with the Text to SQL tool.
| CREATE TABLE | INSERT | UPSERT |
|---|---|---|
| Defines the schema: column names, types, and primary key. | Loads new rows. Fails on a duplicate primary key. | Inserts new rows and updates existing ones, keyed on the PK. |
| Runs once before the data is loaded. | Runs after the table exists, batched 1000 rows per statement. | Uses ON DUPLICATE KEY UPDATE, ON CONFLICT DO UPDATE, or MERGE by dialect. |
Optional, paired with an optional DROP TABLE. | The default body of the output. | Best for re-running the same JSON without primary-key collisions. |
A JSON to SQL converter reads JSON data and generates SQL statements that recreate the data in a database. This tool builds a CREATE TABLE statement with inferred column types and INSERT statements for every object, ready to paste into a SQL client.
The converter generates dialect-specific SQL for MySQL, PostgreSQL, SQLite, SQL Server, and Oracle. Each dialect uses the correct identifier quoting, data type names, JSON storage type, and boolean handling so the output runs without manual edits.
Yes. All parsing and SQL generation happen in your browser with client-side JavaScript, so your JSON data is never uploaded to a server. Private records stay on your device.
The tool inspects every value in a column and picks the narrowest fit: BOOLEAN, then INTEGER, then a decimal type, then DATE or a timestamp type, and finally a VARCHAR sized to the longest value or TEXT past 255 characters. Nested objects and arrays use the dialect's JSON storage type when in Stringify mode.
Pick one of two strategies. Flatten turns nested objects into columns named with underscore-joined paths, for example address.city becomes address_city. Stringify stores each nested object or array as a JSON value in a single column using JSON, JSONB, NVARCHAR(MAX), CLOB, or TEXT depending on the dialect.
Yes. If the root is a single JSON object the tool wraps it in an array automatically and emits one INSERT row, so you don't need to reshape the input.
Yes. Toggle CREATE TABLE and DROP TABLE IF EXISTS independently, and choose between a single batched multi-row INSERT or one INSERT per row. You control exactly which statements appear.
The tool computes the union of keys across every object and emits NULL for any key that is missing in a row, so heterogeneous arrays convert cleanly without ragged output.
Yes. Switch the Upsert mode on and the output uses ON DUPLICATE KEY UPDATE for MySQL, ON CONFLICT (pk) DO UPDATE for PostgreSQL and SQLite, and a MERGE statement for SQL Server and Oracle, keyed on the detected primary-key column.
When Auto primary key is on, the tool looks for an id, uuid, or any column ending in _id and marks it as PRIMARY KEY in the CREATE TABLE. For integer keys it also adds the dialect's auto-increment clause (AUTO_INCREMENT, SERIAL, IDENTITY(1,1), AUTOINCREMENT, or GENERATED AS IDENTITY).
Yes, the converter is completely free with no signup or credit card required. Inputs are capped at 2 MB to keep browser conversion responsive; for larger files split the JSON or use a server-side script.
The CSV to SQL converter takes tabular CSV input, while this tool takes structured JSON with native types, nested objects, and arrays. Use JSON to SQL when you have API responses, NoSQL exports, or any document-shaped data, and CSV to SQL for spreadsheet exports.
Did you find this page helpful?
TestMu AI forEnterprise
Get access to solutions built on Enterprise
grade security, privacy, & compliance