Back to Tools

JSON to SQL Converter

Convert JSON arrays/objects into SQL INSERT statements instantly

CONVERTER PRO
Source JSON (Array of Objects)
SQL Script Output

                

From a JSON array to ready-to-run INSERT statements

APIs and exports hand you JSON, but databases want rows. Loading a list of records usually means writing a script or hand-editing dozens of INSERT lines. JSON to SQL does the mechanical part: it reads an array of objects, treats each object as a row and each key as a column, and prints one INSERT statement per record for the table name you supply.

Converting your data

  1. Type your table name into Target Table Name. It starts as my_table.
  2. Paste your JSON into the Source JSON (Array of Objects) box using the Paste button, or click Sample to see an example. Clear resets the box.
  3. Click Generate SQL INSERT Statements.
  4. Use Copy Script in the SQL Script Output panel to grab the result.

The script begins with a comment line noting how many records were found, followed by one statement for each object, such as INSERT INTO users (`id`, `name`) VALUES (1, 'Jane');

How values are written

  • Strings are wrapped in single quotes, and any single quote inside the text is doubled so the statement stays valid.
  • Null values become NULL.
  • Numbers and booleans are written as they appear, without quotes.
  • If you paste a single object instead of an array, it is treated as a one-row list.

Where you would use it

  • Seeding a development database with sample records copied from an API response.
  • Moving a small export from a document store into a relational table.
  • Building test fixtures for a bug report.
  • Turning a settings list into a quick data migration script.

Limits to keep in mind

Column names come from the keys of the first object only, and the same keys are used for every row. If later records have extra fields, those fields are ignored, and if they are missing a key the statement will contain the text undefined, so make your objects consistent first. Column names are wrapped in backticks, which suits MySQL and MariaDB; PostgreSQL and SQL Server users will need to replace them with double quotes or square brackets. Nested objects and arrays are not converted into JSON columns, so flatten them beforehand. The table name is used as typed, without quoting, and the tool creates no CREATE TABLE statement, so the table must already exist. Invalid JSON produces an error message instead of output. Review the script before running it against any live database. Conversion takes place in your browser.

Related Tools


Frequently Asked Questions

What JSON structure does the converter expect?
An array of flat objects, where each object is a row and each key is a column, such as [{"id":1,"name":"Jane"}]. A single object also works and produces one INSERT. Nested objects and arrays are not converted.
Does it create the table for me?
No. It only generates INSERT statements, so the table with matching column names must already exist. You can write the CREATE TABLE statement yourself and run it first, then run the generated script.
Will the script work in PostgreSQL or SQL Server?
Not without a small edit. Column names are wrapped in backticks, which MySQL accepts. For PostgreSQL replace them with double quotes, and for SQL Server use square brackets. The values themselves use standard single-quote escaping.
What happens when records have different keys?
The column list is taken from the first object only. Keys that appear later are ignored, and a key missing from a later object is output as undefined, which is not valid SQL. Make all objects share the same keys first.
How are quotes inside text handled?
Any single quote inside a string value is doubled, so O'Brien becomes 'O''Brien' in the statement. That is the standard SQL way to escape it. Double quotes inside the text are left as they are.
Support Chat
We typically reply within minutes

Hello! 👋 Before we start, please tell us your name.