Generate an INSERT statement from a JSON object (one row) or an array of objects (several rows). Columns come from the keys, are checked against an allowlist of characters and quoted per dialect.
Values are never written into the SQL: they go as separate parameters using the placeholder of each dialect’s usual driver ($1 for PostgreSQL, ? for MySQL, @p1 for SQL Server, :1 for Oracle). This prevents SQL injection even when a value contains quotes or semicolons.
How to use it
- Enter the table name (optionally schema.table).
- Choose the dialect.
- Paste the JSON and press Run.
- Use the statement in your code and pass the parameter list to the driver.
Example
[
{"id": 1, "email": "ana@example.com", "active": true, "note": null},
{"id": 2, "email": "luis@example.com", "active": false, "note": "O'Brien; DROP TABLE x"}
] INSERT INTO "app"."users" ("id", "email", "active", "note")
VALUES ($1, $2, $3, $4),
($5, $6, $7, $8);
-- Parameters in order ($1, $2… (node-postgres, libpq)):
-- [1, "ana@example.com", true, null, 2, "luis@example.com", false, "O'Brien; DROP TABLE x"] Limitations
- Every row must have the same columns in the same order.
- Object or array values are rejected: serialize them to a string if the column is JSON.
- At most 1000 rows; Oracle does not support multi-row VALUES before 23ai.
FAQ
- Why are the values not inside the INSERT?
- Because interpolating values into SQL is the classic cause of injection. The parameterized query is sent to the server separately from the data.
- Why are names quoted?
- So reserved words such as user or order work as identifiers. Note that quoting is case-sensitive in PostgreSQL and Oracle.