Hero Background

Next-Gen App & Browser Testing Cloud

Trusted by 2 Mn+ QAs & Devs to accelerate their release cycles

Next-Gen App & Browser Testing Cloud

Free JSON to SQL Converter Online - TestMu AI (Formerly LambdaTest)

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.

JSON Input

Options

Select
Select
Select

SQL Output

What is a JSON to SQL Converter?

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.

How does the JSON to SQL Converter work?

The converter parses your JSON in the browser, infers a schema, and reassembles the data as SQL. It runs five steps in order.

  • Parsing: JSON.parse reads the input. Arrays of objects pass through; a single object is wrapped into a one-row array.
  • Schema inference (union of keys): every object contributes its keys to a single union schema, so heterogeneous shapes still convert cleanly. Missing keys are emitted as NULL.
  • Type inference: each column is scanned for the narrowest fit, choosing BOOLEAN, INTEGER, a decimal type, DATE, a timestamp type, or a sized VARCHAR that falls back to TEXT past 255 characters.
  • Nested JSON strategy: nested objects and arrays are either flattened into dot-path columns or stored as JSON values in the dialect's JSON type.
  • Dialect mapping & escaping: identifiers are quoted per database (backticks for MySQL, square brackets for SQL Server, double quotes elsewhere), single quotes in strings are doubled, and booleans render as 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.

How to use this JSON to SQL Converter

  • Add your JSON: paste it into the JSON Input box, upload a .json or .txt file, or press the sample button to load an example with nested objects and arrays.
  • Set the table name and dialect: name the target table and pick MySQL, PostgreSQL, SQLite, SQL Server, or Oracle.
  • Choose a nested-JSON strategy: Flatten turns nested objects into parent_child columns; Stringify stores them as JSON in a single column.
  • Tune the options: toggle CREATE TABLE, DROP TABLE, batch INSERT, NULL handling, Auto primary key, Upsert mode, and the transaction wrapper.
  • Read the output: with Auto update on the SQL refreshes as you type, or press Convert to SQL to run it on demand.
  • Copy or download: use the copy button or download the statements as a .sql file for your migration.

Supported SQL dialects

DialectIdentifier quoteInteger PK auto-incrementJSON storage type
MySQL`name`AUTO_INCREMENTJSON
PostgreSQL"name"SERIALJSONB
SQLite"name"INTEGER PRIMARY KEY AUTOINCREMENTTEXT
SQL Server[name]IDENTITY(1,1)NVARCHAR(MAX)
Oracle"name"GENERATED BY DEFAULT AS IDENTITYCLOB

How nested JSON is handled

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:

  • Flatten (default): columns become 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.
  • Stringify as JSON: columns become 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 to SQL type mapping

JSON valueMySQLPostgreSQLSQLiteSQL ServerOracle
BooleanTINYINT(1)BOOLEANINTEGERBITNUMBER(1)
Integer numberINTINTEGERINTEGERINTNUMBER(10)
Decimal numberDOUBLEDOUBLE PRECISIONREALFLOATNUMBER
String (YYYY-MM-DD)DATEDATETEXTDATEDATE
String (ISO timestamp)DATETIMETIMESTAMPTEXTDATETIME2TIMESTAMP
String (short)VARCHAR(n)VARCHAR(n)TEXTNVARCHAR(n)VARCHAR2(n)
String (> 255)TEXTTEXTTEXTNVARCHAR(MAX)CLOB
Object / array (Stringify mode)JSONJSONBTEXTNVARCHAR(MAX)CLOB

Use cases of the JSON to SQL Converter

  • Seeding test data: turn a JSON fixture into INSERT statements, then run the checks that consume them across browsers and devices with TestMu AI Test Manager.
  • API response import: drop a JSON response from a REST endpoint into a relational table for analysis.
  • NoSQL to SQL migration: convert a MongoDB or DynamoDB export to a SQL schema you can load into Postgres or MySQL.
  • Prototyping: stand up a sample table in SQLite or PostgreSQL from a JSON document in seconds.
  • Learning SQL: compare the generated 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.

Difference between INSERT, CREATE TABLE, and UPSERT

CREATE TABLEINSERTUPSERT
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.

Frequently Asked Questions (FAQs)

What is a JSON to SQL converter?

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.

Which SQL databases does this tool support?

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.

Does the JSON to SQL converter run in my browser?

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.

How does the tool decide each column's data type?

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.

How does the converter handle nested objects and arrays?

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.

Can I convert a single JSON object instead of an array?

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.

Can I generate only the CREATE TABLE or only the INSERT rows?

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.

How are missing keys handled when objects have different shapes?

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.

Does the tool support UPSERT or ON CONFLICT statements?

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.

How does Auto primary key detection work?

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).

Is the JSON to SQL converter free, and is there a size limit?

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.

How does this differ from your CSV to SQL converter?

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

  • Advanced access controls
  • Advanced data retention rules
  • Advanced Local Testing
  • Premium Support options
  • Early access to beta features
  • Private Slack Channel
  • Unlimited Manual Accessibility DevTools Tests