Convert JSON to SQL INSERT statements
Need to load a JSON export into a database? This tool turns a JSON array of objects into one SQL INSERT statement per row, ready to paste into psql, the MySQL client or SQL Server, with the escaping and identifier quoting handled for you.
How it works
The generator collects the column list from the union of all object keys, so a
key missing from some rows still gets a column. For each object it emits one
INSERT INTO table (cols) VALUES (...) line, choosing literals by type:
| JSON value | SQL literal |
|---|---|
| string | 'text' (single quotes doubled) |
| number | unquoted, e.g. 42 |
| boolean | TRUE / FALSE |
| null or missing key | NULL |
Picking a dialect changes how identifiers are quoted when quoting is enabled: PostgreSQL and SQL Server style differ from MySQL.
| Dialect | Identifier quoting |
|---|---|
| PostgreSQL | "name" |
| MySQL | `name` |
| SQL Server | [name] |
Example
This JSON:
[ { "id": 1, "name": "O'Hara", "active": true } ]
with table users generates:
INSERT INTO users (id, name, active) VALUES (1, 'O''Hara', TRUE);
The apostrophe in O'Hara was escaped by doubling it, the number stays
unquoted, and the boolean became TRUE.
Everything runs locally in your browser — nothing is uploaded, which makes it safe for confidential data and exports.
Common situations where this helps
Loading seed data. Development and staging databases need test fixtures. If your seed data is maintained as JSON (a natural format for version control), this tool converts it to runnable INSERT statements without writing a migration script.
Migrating from a JSON API to a relational database. When a system previously stored everything in JSON files or a document database and you are moving to Postgres or MySQL, this tool handles the initial data load.
Quick data imports in a hurry. When you have a JSON export from one system and need to get it into a SQL database without setting up an ETL pipeline, a few INSERT statements are often the fastest path.
Dialect differences explained
The tool supports three SQL dialects, which differ mainly in how identifiers (table names, column names) are quoted:
| Dialect | Quote character | Example |
|---|---|---|
| PostgreSQL | Double quotes | INSERT INTO "users" ("id", "name") VALUES ... |
| MySQL | Backticks | INSERT INTO `users` (`id`, `name`) VALUES ... |
| SQL Server | Square brackets | INSERT INTO [users] ([id], [name]) VALUES ... |
Quoting identifiers prevents conflicts with reserved words — a column named order or user would cause a parse error without quotes. This tool quotes all identifiers by default.
String escaping and SQL injection
The only string escaping this tool applies is doubling single quotes (the standard SQL way). For example, O'Brien becomes 'O''Brien'. This is sufficient for generating INSERT statements to run directly in a trusted SQL client.
Important: the output of this tool is intended for trusted database clients and migration scripts, not for constructing SQL dynamically in application code. Always use parameterised queries in application code to prevent SQL injection — never construct SQL by string concatenation from user input.
Handling NULL and missing values
When an object in the JSON array does not have a key that appears in other objects, the missing value is emitted as NULL. For example:
[
{ "id": 1, "name": "Alice", "email": "[email protected]" },
{ "id": 2, "name": "Bob" }
]
generates:
INSERT INTO users (id, name, email) VALUES (1, 'Alice', '[email protected]');
INSERT INTO users (id, name, email) VALUES (2, 'Bob', NULL);
Bob’s missing email becomes NULL, keeping the column list consistent across all rows.