Turn your JSON data into ready-to-run SQL in seconds
Paste any JSON array and this tool generates a CREATE TABLE statement plus matching INSERT INTO statements you can run straight in MySQL, PostgreSQL, SQLite, or any other SQL database. No manual column-picking, no typing values by hand.
Input (JSON array):
[
{ "id": 1, "name": "Alice", "active": true },
{ "id": 2, "name": "Bob", "active": false }
]
Output (SQL):
CREATE TABLE my_table (
id INTEGER,
name VARCHAR(255),
active BOOLEAN
);
INSERT INTO my_table (id, name, active) VALUES (1, 'Alice', true);
INSERT INTO my_table (id, name, active) VALUES (2, 'Bob', false);
Paste your JSON above, copy or download the SQL. The tool auto-detects numbers, booleans, and strings — nothing is uploaded; the entire conversion runs in your browser.
How to use this JSON-to-SQL converter
- Paste your JSON into the input box above. It must be an array of objects (each object becomes one row).
- Set a table name if you want something other than the default
my_table. - Choose your SQL dialect (MySQL, PostgreSQL, SQLite — or leave it on Standard SQL).
- Click Convert. The CREATE TABLE + INSERT statements appear instantly.
- Copy the output or hit Download to save a
.sqlfile.
Realistic worked example
Say you exported a list of products from an API and got this JSON back:
[
{ "product_id": 101, "title": "Wireless Mouse", "price": 29.99, "in_stock": true },
{ "product_id": 102, "title": "Mechanical Keyboard", "price": 89.50, "in_stock": false },
{ "product_id": 103, "title": "USB-C Hub", "price": 45.00, "in_stock": true }
]
The converter reads every key as a column, sniffs the data types, and produces:
CREATE TABLE my_table (
product_id INTEGER,
title VARCHAR(255),
price DECIMAL(10,2),
in_stock BOOLEAN
);
INSERT INTO my_table (product_id, title, price, in_stock)
VALUES (101, 'Wireless Mouse', 29.99, true);
INSERT INTO my_table (product_id, title, price, in_stock)
VALUES (102, 'Mechanical Keyboard', 89.50, false);
INSERT INTO my_table (product_id, title, price, in_stock)
VALUES (103, 'USB-C Hub', 45.00, true);
Paste that directly into your database client and the table is ready to query. No column guessing, no escaping strings by hand.
How to do this in Python or JavaScript
If you need to automate the conversion in your own code, here are minimal, copy-pasteable snippets.
Python
import json
data = [
{"id": 1, "name": "Alice", "active": True},
{"id": 2, "name": "Bob", "active": False},
]
table = "users"
columns = list(data[0].keys())
cols_str = ", ".join(columns)
print(f"INSERT INTO {table} ({cols_str}) VALUES")
for row in data:
vals = ", ".join(
str(v) if not isinstance(v, str) else f"'{v}'"
for v in row.values()
)
print(f" ({vals});")
Run with Python 3.6+. For production use, swap string formatting for a proper library like SQLAlchemy to avoid SQL injection risks.
JavaScript (Node.js)
const data = [
{ id: 1, name: 'Alice', active: true },
{ id: 2, name: 'Bob', active: false },
];
const table = 'users';
const cols = Object.keys(data[0]).join(', ');
data.forEach(row => {
const vals = Object.values(row)
.map(v => typeof v === 'string' ? `'${v}'` : v)
.join(', ');
console.log(`INSERT INTO ${table} (${cols}) VALUES (${vals});`);
});
Works in Node.js 12+ or any modern browser console. For real apps, use a parameterised query library to keep your data safe.
How it works
The converter reads your JSON array and uses the first object's keys as column names. It then scans every value across all rows to infer the best SQL data type: integers become INTEGER, decimals become DECIMAL, true/false become BOOLEAN, and everything else becomes VARCHAR(255). String values are automatically escaped (single quotes are doubled) so the output is safe to paste.
All of this runs entirely inside your browser. Your JSON is never sent to any server, so sensitive data stays private on your machine.
When to use it — and when not to
| Use it when… | Consider something else when… |
|---|---|
| You have a flat JSON array from an API or export | Your JSON is deeply nested (you'll need to flatten it first) |
| You want a quick schema + seed data for a new table | You're migrating millions of rows (use a database import tool instead) |
| You're prototyping or writing a quick data import script | You need stored procedures, indexes, or foreign keys generated |
| You want to share a dataset as portable SQL | Your data has mixed or inconsistent types per column |
Need to clean or inspect your JSON first?
If your JSON looks messy or you're not sure it's valid, run it through the JSON Beautifier — Format, Validate & Minify JSON Online or check it with the JSON Validator — Check & Fix JSON Errors Online before converting.
Working with large minified blobs? The JSON Minifier — Compress & Minify JSON Online and JSON Viewer — View, Format & Validate JSON Online are handy for prepping your data. If you also need a YAML export, try the JSON to YAML Converter or JSON Pretty Print to format it for reading.
The JSON data format is defined by json.org, and the SQL INSERT syntax is covered in the ISO/IEC SQL standard (most databases follow it closely, with small dialect differences).
Bottom line: if you have a JSON array and need SQL INSERT statements in under a minute, paste it into the converter above and you're done.