Skip to content
{ }JSON Formatter

JSON to SQL — Generate INSERT Statements

Turn a JSON array of objects into SQL INSERT statements — one per row or a single multi-row insert, with correct quoting for Standard SQL, MySQL or PostgreSQL.

JSON (array of objects)
SQL
Generated. Review before running against a real database.

From API data to seed script

A JSON array is the natural output of an API or an export; a stack of INSERT statements is what a database wants. This tool bridges them: each object becomes a row, the union of all keys becomes the column list, and values are turned into safe SQL literals — strings single-quoted and escaped (so O'Brien is written 'O''Brien'), numbers and true/false/null as their SQL equivalents, and nested objects or arrays stored as their JSON text.

Dialects & row style

The only dialect difference is identifier quoting — MySQL uses `backticks`, Standard SQL and PostgreSQL use "double quotes". Pick one statement per row for readable, diff-friendly output, or multi-row (INSERT … VALUES (…),(…),(…)) for a faster bulk load. Rows with different keys are handled by unioning the columns and writing NULL where a value is absent.

Review before you run

The value escaping is correct, but treat generated SQL as a draft: check the table name (you type it), confirm column names match your schema, and mind data types your database enforces. Need to reshape the JSON first — pick specific fields, flatten nested objects? Use the JSONPath filter or JSON Flatten before generating.

Frequently asked questions

What JSON shape does it expect?

An array of objects — each object becomes a row, and the union of all keys becomes the column list. A single object produces one INSERT. Objects with different keys are fine: missing values become NULL.

How are strings and special characters escaped?

String values are single-quoted with SQL-standard escaping: a single quote inside a value is doubled, so a name containing an apostrophe is written safely and cannot break the statement or allow injection. Numbers, true/false and null map to SQL literals; nested objects or arrays are stored as their JSON text in a single quoted value.

What is the difference between the dialects?

Only identifier quoting: MySQL uses backticks (`col`), Standard and PostgreSQL use double quotes ("col"). The values and structure are identical. Pick the one your database expects, or Standard if unsure.

Single statements or one multi-row INSERT?

Your choice. One INSERT per row is easy to read and diff; a single multi-row INSERT ... VALUES (…),(…) is faster to execute for bulk loads. Toggle "multi-row" to switch.

Is this safe to run directly?

The escaping is correct for the literal values shown, but always review generated SQL before running it against a real database — especially the table name, which you type yourself. Everything is generated in your browser; nothing is uploaded.