JSON to SQL Converter

Paste a JSON array of objects to get CREATE TABLE and INSERT statements. Every object becomes a row and every key becomes a column.

Advertisement

Convert JSON to SQL INSERT statements

API responses, NoSQL exports and seed files are usually JSON. This converter turns a JSON array into a SQL script you can run to load the same records into a relational database — useful for seeding a development database, migrating from MongoDB or Firebase, or importing data from a REST API.

Keys from all objects are combined into one column list, so objects with missing fields simply get NULL there. Nested objects and arrays are stored as JSON text. If your JSON wraps the array in an object, such as { "data": [ ... ] }, the array is found automatically.

Example

JSON input:

[
  { "id": 1, "name": "Sara Khan", "email": "sara@example.com", "active": true },
  { "id": 2, "name": "Ali Raza", "email": null, "active": false }
]

SQL output for PostgreSQL with the table name customers:

CREATE TABLE "customers" (
  "id" INTEGER,
  "name" VARCHAR(255),
  "email" VARCHAR(255),
  "active" BOOLEAN
);

INSERT INTO "customers" ("id", "name", "email", "active") VALUES
(1, 'Sara Khan', 'sara@example.com', TRUE),
(2, 'Ali Raza', NULL, FALSE);

Have a spreadsheet instead? Use the CSV to SQL converter. To check or tidy the JSON first, use the JSON formatter.

Frequently asked questions

What JSON shape does it accept?
An array of objects, a single object (one row), or an object that contains an array of objects such as an API response with a "data" or "items" field.
How are nested objects handled?
Nested objects and arrays are written as JSON text in a single column. You can store them in a JSON/JSONB column or split them into separate tables afterwards.
How are null and true/false converted?
null becomes SQL NULL. true/false become TRUE/FALSE in MySQL and PostgreSQL, and 1/0 in SQL Server, SQLite and Oracle.
Is there a size limit?
There is no fixed limit, but very large files (tens of megabytes) may be slow because everything runs in your browser tab.
Is my JSON uploaded anywhere?
No. The conversion runs entirely in your browser, so your data never leaves your computer.

Related tools