paste in · insert statements out

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.

Converter — Ready
Awaiting input
jq-style: .field .[] select(.f == "x")
idle — paste JSON and the statements show up here
0 rows 0 columns SQL output
runs entirely in your browser
nothing is uploaded, ever
no sign-up, no account
free — no paid tier, ever
The basics

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.

Step by step

How to convert JSON to SQL in 4 steps

Most conversions take under a minute. No login, no upload to a server, no installation.

  1. Paste or upload

    Drop a .json file 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.

  2. 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 INSERT per row or a single multi-row INSERT.

  3. Preview

    The generated SQL appears instantly. Check the column list and the literal formatting before you run it anywhere near a real database.

  4. Download or copy

    Click Download .sql to save the script, or select the preview text and copy it straight into your query editor.

Why HopConvert

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.

Comparison

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
Use cases

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.

The complete guide

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.

JSONSQL literalNotes
string'value'Always quoted; internal quotes doubled
number42Emitted unquoted so numeric columns accept it
true / falseTRUE / FALSEStandard SQL keywords
nullNULLNot the string 'null'
object'{...}'Serialised as JSON text
array'[...]'Serialised as JSON text
missing keyNULLWhen 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 in ANSI_QUOTES mode — 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:

  1. Always wrap the whole thing in a transaction — BEGIN; before, COMMIT; after. If one row fails, nothing is half-applied.
  2. Test against a copy first. Run it on a snapshot, not production.
  3. Check the column list against your schema before running. The converter derives columns from the JSON, not from your table.
  4. Use ON CONFLICT DO NOTHING (or INSERT IGNORE) if re-running a backfill.
  5. 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.

FAQ

Frequently asked questions

Everything you need to know about converting JSON to SQL INSERT statements.

What is a JSON to SQL converter?
A JSON to SQL converter transforms a JSON array of records into SQL INSERT statements you can execute against Postgres, MySQL, SQLite, SQL Server, or DuckDB. It derives the column list from the keys in your JSON and formats every value as the correct SQL literal.
Is HopConvert free to use?
Yes. The JSON to SQL converter is 100% free with no sign-up, no watermark, and no premium tier. Everything runs in your browser, so there are no server costs to pass on.
Do I need an account?
No. No account, no email, no personal information. Open the page, paste your JSON, set your table name, and copy the SQL.
Is my data uploaded to a server?
No. The SQL is generated locally in your browser using JavaScript. JSON payloads often contain personal data or production credentials, so this matters — and you can verify it live with the "Verify: nothing uploaded" button on the page.
Which SQL dialects are supported?
PostgreSQL and ANSI SQL (double-quoted identifiers, standard literal escaping) and MySQL (backtick identifiers, backslash escaping). You can also turn identifier quoting off entirely for migration tools that prefer bare names.
How does it handle null and booleans?
JSON null becomes SQL NULL, booleans become TRUE and FALSE, and numbers are written unquoted so numeric columns accept them. This is the part hand-written SQL most often gets wrong.
Can I generate a multi-row INSERT?
Yes — that is the default, because a single batched statement is far faster than thousands of individual inserts. You can switch to one statement per row in settings if your migration tooling prefers it.
How do I set the table name and schema?
Open the settings cog and type the table name, plus an optional schema. The generated statements use them directly, so you can produce INSERT INTO "public"."users" or INSERT INTO `analytics`.`events` depending on the dialect.
What happens to nested objects?
Nested objects are flattened into column names joined by __, 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?
The SQL is generated from your data, but it is still code. Wrap the import in a transaction, test it against a copy of your data first, and check the generated column list against your schema before running it.

Generate the INSERTs

Free, instant, and private — your JSON never leaves this tab.

Start Converting Read the FAQ