JSON to SQL Converter - Generate INSERT Statements Free

Convert JSON to SQL INSERT statements instantly. Auto-detects column types, generates CREATE TABLE too. Runs in your browser - free, no sign-up.

JSON
111 chars · 4 lines · 111 bytes
SQL

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.

Quick snapshot — JSON to SQL:
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

  1. Paste your JSON into the input box above. It must be an array of objects (each object becomes one row).
  2. Set a table name if you want something other than the default my_table.
  3. Choose your SQL dialect (MySQL, PostgreSQL, SQLite — or leave it on Standard SQL).
  4. Click Convert. The CREATE TABLE + INSERT statements appear instantly.
  5. Copy the output or hit Download to save a .sql file.

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.

Frequently asked questions

Does my JSON get uploaded to a server?+
No. The conversion runs entirely in your browser using client-side JavaScript. Your data never leaves your device, so it's safe to paste in API keys, passwords, or any other sensitive content.
What JSON format does the tool expect?+
It expects a JSON array of objects, like [{"id": 1, "name": "Alice"}, {"id": 2, "name": "Bob"}]. Each object becomes one row, and the keys become column names. A single object (not wrapped in an array) will also work - it generates one INSERT row.
Which SQL dialects does the converter support?+
The tool outputs standard SQL that works in MySQL, PostgreSQL, SQLite, and SQL Server. Minor syntax differences (like backtick vs. double-quote identifiers) can usually be fixed in one search-and-replace after downloading.
How are data types detected?+
The converter checks every value in each column. All-integer values map to INTEGER, numbers with decimals map to DECIMAL, true/false values map to BOOLEAN, and anything else maps to VARCHAR(255). If a column has mixed types, it defaults to VARCHAR to stay safe.
What happens if my JSON is nested (objects inside objects)?+
Nested objects and arrays are serialised as text strings in the SQL output - they won't be expanded into separate tables automatically. Flatten your JSON first if you need a proper relational schema. A tool like Python's pandas.json_normalize() is handy for that.
Can I convert JSON to SQL in Python without a tool?+
Yes. Loop over your JSON array, build an INSERT string for each row, and print or write it to a file. The snippet in the 'How to do this in Python' section above shows the pattern. For anything going into a real database, use parameterised queries (e.g. via SQLAlchemy or psycopg2) to avoid SQL injection.
Is there a file size limit? Can it handle large datasets?+
Because everything runs in the browser, very large files (tens of thousands of rows) can slow down your tab. For bulk imports - think hundreds of thousands of rows - it's better to use a database's native import tool (like MySQL's LOAD DATA or PostgreSQL's COPY command) rather than generating individual INSERT statements.
Is the tool free? Do I need to sign up?+
It's completely free and requires no account or sign-up. Paste your JSON, get your SQL, and leave - nothing is tracked or stored.