JSON to SQL INSERT Generator

Convert a JSON array of objects into SQL INSERT statements.

What This Tool Does

This tool converts a JSON array of objects into a single, ready-to-run SQL INSERT statement. Paste an array like [{"id": 1, "name": "Alice"}, {"id": 2, "name": "Bob"}], set a table name, and it generates a multi-row INSERT INTO statement covering every object in the array.

Use the Table name field above the editors to set the target table. If you leave it blank, the tool falls back to my_table. Column names are collected as the union of keys found across all objects in the array, so if some objects are missing a field, that field becomes NULL for those rows.

Identifiers (table and column names) are wrapped in backticks (`), which is MySQL and MariaDB syntax. Values are converted based on type: null and undefined become NULL, numbers and booleans are written unquoted, and strings and objects are single-quoted with backslashes and single quotes escaped so the resulting SQL is syntactically valid.

How to Use It

  1. Paste a JSON array of objects into the Input box. Each object should represent one row to insert.
  2. Set the Table name field to the name of your destination table (defaults to my_table if left blank).
  3. Click Run to generate the SQL statement.
  4. Copy the result from the Output box.
  5. Review the generated statement, confirm the table structure already exists in your database, and execute it with your SQL client or migration tool.

Worked Example

Table name: customers

Input JSON:

[
  { "id": 1, "name": "O'Brien", "active": true, "notes": null },
  { "id": 2, "name": "Ana \"Lee\"", "active": false, "notes": "VIP" },
  { "id": 3, "name": "Sam\\Corp", "active": true, "notes": "Path: C:\\data" }
]

Generated SQL:

INSERT INTO `customers` (`id`, `name`, `active`, `notes`) VALUES
  (1, 'O''Brien', true, NULL),
  (2, 'Ana "Lee"', false, 'VIP'),
  (3, 'Sam\\Corp', true, 'Path: C:\\data');

Notice how the apostrophe in O'Brien becomes a doubled single quote (''), the backslash in Sam\Corp is doubled to \\, and the third row's missing-value cases show how a JSON null becomes SQL NULL while booleans (true/false) are written unquoted.

Common Use Cases

SQL Dialect Notes

This generator produces MySQL/MariaDB-style SQL: identifiers are wrapped in backticks (`table`, `column`), which is the quoting convention those databases use. This is not standard ANSI SQL.

PostgreSQL uses double quotes for identifiers instead of backticks ("table", "column"). If you are targeting Postgres, replace the backticks with double quotes before running the statement, or drop the quoting altogether if your table and column names are lowercase and contain no special characters or reserved words. SQL Server uses square brackets ([table]) by convention, which also requires a manual swap.

Frequently Asked Questions

What table name does it use by default?

If you leave the Table name field blank, the tool defaults to my_table.

Does it create the table (CREATE TABLE)?

No, it only generates INSERT statements. The table structure needs to already exist in your database before you run the generated SQL.

Is my data uploaded anywhere?

No. Conversion runs entirely in your browser via JavaScript — your JSON never leaves your machine.

Will this work with PostgreSQL or SQL Server?

The generated SQL uses MySQL/MariaDB-style backtick-quoted identifiers. For PostgreSQL, swap the backticks for double quotes; for SQL Server, swap them for square brackets.

What if my objects have different sets of keys?

The tool builds its column list from the union of all keys across every object. Rows missing a given key will get NULL for that column.

Related Tools & Guides

Partner tools