JSON to SQL Converter — your dialect, not ours
Paste JSON and get INSERT statements ready to run. Choose your table name and your dialect — Postgres, MySQL, SQLite — and the SQL matches. Nothing is sent anywhere.
.field .[] select(.f == "x")
What is a JSON to SQL converter?
A JSON to SQL converter turns structured JSON data into SQL INSERT statements — the exact commands you need to load that data into a relational database. Most teams hit this constantly: an API returns JSON, a webhook fires with a JSON payload, a backfill script reads a JSON export, and the target is Postgres, MySQL, SQLite, SQL Server, or DuckDB.
Writing those statements by hand is slow and error-prone. One forgotten quote around a value containing an apostrophe and your import fails halfway, leaving the table half-populated. The value types are just as easy to get wrong: a JSON null must become SQL NULL, not the string "null"; a boolean must become TRUE/FALSE; a number must not be quoted if the column is numeric.
HopConvert handles all of that. It reads the union of keys across your records to build the column list, quotes identifiers according to your dialect (double quotes for PostgreSQL and ANSI SQL, backticks for MySQL), escapes string literals correctly, renders null and booleans as proper SQL keywords, and formats numbers as bare numeric literals. You set the table name and schema once and the statements are ready to paste into psql, MySQL Workbench, or a migration file.
Everything runs in your browser, so nothing is uploaded. That matters more here than for other converters: JSON payloads often contain personal data, internal identifiers, or credentials pulled from a production environment.
How to convert JSON to SQL in 4 steps
Most conversions take under a minute. No login, no upload to a server, no installation.
-
Paste or upload
Drop a
.jsonfile into the upload zone or paste a JSON array of objects into the box. A single object works too — it becomes a one-row insert. -
Set up the statement
Open the settings cog to set the table name, an optional schema, the dialect (PostgreSQL/ANSI or MySQL), and whether to emit one
INSERTper row or a single multi-rowINSERT. -
Preview
The generated SQL appears instantly. Check the column list and the literal formatting before you run it anywhere near a real database.
-
Download or copy
Click Download .sql to save the script, or select the preview text and copy it straight into your query editor.
Built for the JSON your API actually returns
Real payloads are nested, sparse, and full of nulls. HopConvert produces SQL you can run without hand-fixing.
Dialect-aware quoting
PostgreSQL and ANSI SQL use double-quoted identifiers; MySQL uses backticks. String literals are escaped per dialect, so apostrophes in O'Brien-style names are handled correctly.
Correct literals, every time
JSON null becomes NULL, booleans become TRUE/FALSE, and numbers are emitted unquoted so numeric columns accept them.
Union of all columns
Records with different keys still produce one consistent column list, with missing values written as NULL.
Browser-only privacy
API payloads often contain personal data or internal identifiers. Everything is generated locally in JavaScript — nothing is transmitted or stored.
Multi-row or per-row inserts
A single batched INSERT is dramatically faster than thousands of individual statements. Pick whichever your migration tool prefers.
jq-style filtering
Load only the rows you need with select(.status == "paid") before the SQL is generated.
Generated SQL vs hand-written SQL
The difference shows up the moment a value contains a quote, a null, or a boolean.
| Aspect | Hand-written | HopConvert |
|---|---|---|
| Apostrophes in values | Easy to get wrong — breaks the statement | Escaped automatically |
| JSON null vs "null" | Often confused | Rendered as SQL NULL |
| Booleans | 0/1 or TRUE/FALSE, inconsistent | TRUE / FALSE |
| Missing keys across records | Column list gets out of sync | Union of all keys |
| Table and schema name | Repeatedly retyped | Set once in settings |
| Dialect differences | Easy to miss | ANSI or MySQL quoting |
| Time to first statement | Minutes for a big payload | Instant |
When teams reach for JSON to SQL
Anywhere JSON needs to land in a relational database, this is the shortest path.
Seeding a local database
Pull a fixture from an API or a repository and turn it into INSERT statements so a new developer has realistic data in seconds.
Webhook payload replay
Capture the JSON body a partner sent, convert it to SQL, and replay it into a staging table to reproduce a bug.
Backfilling a column
Export a JSON snapshot of one field, generate a bulk UPDATE-friendly set of rows, and patch historical records.
Data migration scripts
Turn a JSON export from a legacy system into a checked-in .sql migration file your team can review before it runs.
Analytics table loads
Convert an API export to INSERT statements and bulk-load it into Postgres, MySQL, DuckDB, or SQLite for analysis.
Test fixtures
Generate deterministic INSERT statements for integration tests instead of hand-maintaining a seed file.
JSON to SQL: the complete guide
Everything about turning JSON into SQL INSERT statements — types, quoting, dialects, and the mistakes that break an import.
Read the full JSON to SQL guide
Related tools: JSON to CSV guide · JSON to Excel
Why convert JSON to SQL?
JSON is the default format for everything that talks over HTTP. SQL is the default format for everything that stores relations. Almost every system you work with has to move data between the two — and the conversion is where data quietly gets corrupted.
The usual sources are:
- API responses into a local database — for exploration, for a demo, or for a fixture file.
- Webhook payloads into a queue table — so you can inspect what a partner actually sent.
- Legacy exports into a new system — the old system exports JSON, the new system wants rows.
- Third-party datasets — a vendor sends a JSON file, your warehouse wants a bulk load.
How do JSON types map to SQL types?
The mapping is mostly obvious, and mostly where imports break.
| JSON | SQL literal | Notes |
|---|---|---|
string | 'value' | Always quoted; internal quotes doubled |
number | 42 | Emitted unquoted so numeric columns accept it |
true / false | TRUE / FALSE | Standard SQL keywords |
null | NULL | Not the string 'null' |
object | '{...}' | Serialised as JSON text |
array | '[...]' | Serialised as JSON text |
| missing key | NULL | When records have different keys |
The single most common bug in hand-written SQL is rendering a JSON null as the quoted string 'null'. Your column then contains the four characters null instead of SQL NULL, and every WHERE x IS NULL query silently returns nothing.
How are identifiers quoted?
SQL identifiers — table names, column names, schema names — have to be quoted differently depending on the database:
- PostgreSQL, SQLite, SQL Server, Oracle, ANSI SQL: double quotes,
"users". This is the SQL standard and the default in HopConvert. - MySQL and MariaDB: backticks,
`users. MySQL also accepts double quotes by default, but only inANSI_QUOTESmode — switching to MySQL quoting avoids ambiguity. - No quoting: also offered, for databases and migration tools that prefer bare identifiers.
Quoting matters for two reasons. First, reserved words — order, group, user, select — are common as column names, and an unquoted reserved word is a syntax error. Second, mixed-case identifiers are folded to lower case by some databases but not others, so quoting is what keeps your column names exactly as you defined them.
How are string literals escaped?
A string literal in SQL is wrapped in single quotes, and any single quote inside it is written twice:
'O''Brien'
That is the ANSI rule and it is what HopConvert emits for PostgreSQL and SQLite. MySQL additionally interprets backslash sequences inside string literals, so a literal backslash must be doubled and control characters must be escaped:
'C:\\path\\to\\file'
'line one\nline two'
HopConvert handles that automatically when the MySQL dialect is selected. Getting this wrong is the classic cause of "syntax error at or near" errors in the middle of an import.
How is the column list decided?
The converter reads every record and builds the column list from the union of all keys, in order of first appearance. Records that lack a key get NULL for that column. This matches the way you would write the CREATE TABLE statement yourself, and it is what makes a sparse JSON array importable without hand-editing.
Nested objects are flattened into column names joined by __ — {"user": {"name": "Alice"}} produces the column user__name. Match that to your schema, or rename the column in the database.
Should I use one INSERT per row or a multi-row INSERT?
Both are valid, and the difference is large in practice.
- One INSERT per row: easy to read, easy to resume, and each statement is independent. But every statement is a round trip, so ten thousand rows means ten thousand round trips.
- A single multi-row INSERT: one statement, one round trip, dramatically faster for bulk loads. Postgres, MySQL, SQLite, and SQL Server all accept it.
For a few dozen rows the difference is irrelevant. For a bulk load it is the difference between seconds and minutes. The multi-row form is the default in HopConvert for that reason.
Very large batches can also hit the maximum statement size in Postgres, so for really big payloads, generate chunks rather than one enormous statement.
Common edge cases
- Top-level object instead of an array: Treated as a single row.
- Top-level array of scalars: Converted to a single column named
value. - Nested arrays and objects: Serialised to JSON text and stored as a text column.
- Missing keys: Written as
NULL. - Numbers beyond JavaScript's safe integer range: JSON.parse loses precision on integers above 2^53-1. For 64-bit IDs, keep them as strings in the source JSON.
- Very long strings: Fine, subject to your database's column limit.
- Unicode and emoji: Written as UTF-8.
Running the generated SQL safely
A few habits make a JSON-to-SQL import far less painful:
- Always wrap the whole thing in a transaction —
BEGIN;before,COMMIT;after. If one row fails, nothing is half-applied. - Test against a copy first. Run it on a snapshot, not production.
- Check the column list against your schema before running. The converter derives columns from the JSON, not from your table.
- Use
ON CONFLICT DO NOTHING(orINSERT IGNORE) if re-running a backfill. - Mind the transaction log. A million-row insert in one transaction can be heavy; chunk it.
And one more thing worth remembering: the generated SQL is generated from data you control, but it is still code. Read it before you run it against anything you care about.
Frequently asked questions
Everything you need to know about converting JSON to SQL INSERT statements.
What is a JSON to SQL converter?
Is HopConvert free to use?
Do I need an account?
Is my data uploaded to a server?
Which SQL dialects are supported?
How does it handle null and booleans?
Can I generate a multi-row INSERT?
How do I set the table name and schema?
INSERT INTO "public"."users" or INSERT INTO `analytics`.`events` depending on the dialect.What happens to nested objects?
__, so {"user": {"name": "Alice"}} becomes the column user__name. Nested arrays and objects are serialised as JSON text in a single column.Is the generated SQL safe to run?
Generate the INSERTs
Free, instant, and private — your JSON never leaves this tab.