JSON to SQL Converter
Convert a JSON array of objects into CREATE TABLE + INSERT statements for any database engine.
100% in your browser — nothing uploadedGenerate CREATE TABLE and INSERT Statements From JSON Data
About the JSON to SQL Converter
This JSON to SQL converter takes an array of JSON objects and generates syntactically correct SQL for your database engine. It infers column types automatically — integers, decimals, booleans, dates, and text — and produces a CREATE TABLE statement plus batched INSERT statements you can run directly.
The converter handles real-world JSON: nested objects and arrays become text columns, missing keys become NULL, and every string value is properly escaped to prevent SQL injection. It also supports newline-delimited JSON (NDJSON) for log files and streaming data. Everything runs in your browser — your data never leaves your device.
How the type inference works
The converter scans every value in each column to decide the narrowest SQL type that fits all of them. It follows a priority chain: if every non-null value is an integer within ±2.1 billion it picks INT; if they exceed that range but are still integers it picks BIGINT; if they have decimal points it picks DECIMAL(p,s) with the minimum precision needed; if any use scientific notation it falls back to DOUBLE/FLOAT. Booleans (true/false) map to BOOLEAN or BIT. Calendar dates (YYYY-MM-DD) map to DATE. Everything else becomes TEXT or VARCHAR.
Example JSON:
[
{"id": 1, "score": 98.5, "active": true, "signup": "2026-03-14"},
{"id": 2, "score": 77.3, "active": false, "signup": "2026-03-15"}
]
Inferred types (PostgreSQL):
id → INTEGER NOT NULL
score → NUMERIC(3,1) NOT NULL
active → BOOLEAN NOT NULL
signup → DATE NOT NULLHandling NDJSON (newline-delimited JSON)
Many logging systems and APIs emit one JSON object per line instead of wrapping everything in an array. This format is called NDJSON. The converter detects it automatically — just paste the lines directly.
{"event": "login", "user": "dana", "ts": "2026-03-14 09:00:00"}
{"event": "purchase", "user": "luis", "ts": "2026-03-14 09:05:23"}
{"event": "logout", "user": "dana", "ts": "2026-03-14 09:12:45"}Quick SQL conversion in Excel, Google Sheets, and the command line
For one-off conversions outside a browser, you can transform JSON to INSERT statements with a few lines of code — but this tool handles type inference, escaping, and dialect differences that quick scripts usually skip.
# jq one-liner (generates naive INSERTs, no type inference)
cat data.json | jq -r '.[] |
"INSERT INTO t VALUES (\(.id), '\(.name)', '\(.signup)');"'
# Python (needs json + string escaping)
import json
with open("data.json") as f:
for row in json.load(f):
vals = ", ".join(repr(v) for v in row.values())
print(f"INSERT INTO t VALUES ({vals});")FAQ
What JSON formats does this tool accept?
It accepts a standard JSON array of objects ([{...}, {...}]), a single JSON object ({...}), and newline-delimited JSON (NDJSON) where each line is a separate JSON object. All three are auto-detected.
How does it handle nested objects or arrays inside JSON?
Nested objects and arrays are stringified (converted to their JSON text representation) and stored as TEXT/VARCHAR columns. This preserves the data without losing information.
Is the generated SQL safe from injection?
Yes. Every string value is escaped using the correct method for the chosen dialect — single quotes are doubled, backslashes are escaped in MySQL, and NUL bytes are stripped. The output is safe to run as-is.