JSON to SQL Converter
Generate CREATE TABLE and INSERT statements from a JSON array for MySQL, PostgreSQL, SQLite or SQL Server.
How to turn JSON into SQL
Paste your JSON array
Paste or type it into the box, or press Try an example. It should be a list of objects.
Choose your database
PostgreSQL, MySQL, SQLite or SQL Server.
Name the table
Set the table name the statements will use.
Copy or download
Run the statements in your database client.
Worked example
This is what JSON to SQL Converter gives for its own sample values. Open the tool above and change anything to try your own.
JSON array
[
{ "id": 1, "name": "Ada Lovelace", "email": "ada@example.com", "active": true, "score": 9.5 },
{ "id": 2, "name": "Linus Torvalds", "email": "linus@example.com", "active": false, "score": 7 },
{ "id": 3, "name": "Grace Hopper", "email": "grace@example.com", "active": true, "score": 10 }
]- Table name
- my_table
- Database
- PostgreSQL
- Include CREATE TABLE
- Yes
- Write empty cells as NULL
- Yes
- Rows per INSERT
- 1
SQL
CREATE TABLE "my_table" (
"id" BIGINT,
"name" VARCHAR(255),
"email" VARCHAR(255),
"active" BOOLEAN,
"score" DOUBLE PRECISION
);
INSERT INTO "my_table" ("id", "name", "email", "active", "score") VALUES (1, 'Ada Lovelace', 'ada@example.com', TRUE, 9.5);
INSERT INTO "my_table" ("id", "name", "email", "active", "score") VALUES (2, 'Linus Torvalds', 'linus@example.com', FALSE, 7);
INSERT INTO "my_table" ("id", "name", "email", "active", "score") VALUES (3, 'Grace Hopper', 'grace@example.com', TRUE, 10);About JSON to SQL Converter
Generate a CREATE TABLE statement and INSERT statements from a JSON array. Nested objects are flattened into columns, and values are typed and escaped for your database.
FAQs
What shape of JSON works?
A list of objects. Each object becomes a row and each key a column.
What about missing keys?
A key missing from some objects becomes NULL for those rows.
Can I start from CSV instead?
Use CSV to SQL Converter.