Skip to content
WORDPRESS, PHP & DATABASE

SQL INSERT Statement Generator from JSON

Generate an escaped SQL INSERT statement from JSON.

  • Free
  • No signup
  • Runs in your browser

This tool runs in your browser. The text you enter is processed on your device and is not sent to NHP Learning.

SQL INSERT Statement Generator

About SQL INSERT Statement Generator

The INSERT statement adds rows to a table. This tool builds one for you from a JSON object or an array of objects. The keys become column names, each object becomes one row in a single multi-row INSERT, and the values are formatted for MySQL.

Numbers stay unquoted, booleans become 1 or 0, null becomes NULL, and text is wrapped in single quotes with quotes and backslashes escaped. To choose the table name, put a first line such as table: users above the JSON. Otherwise the name table_name is used.

How to use SQL INSERT Statement Generator

  1. Optional: type table: your_table on the first line.
  2. Paste a JSON object or array of objects below it and click Run Tool.
  3. Copy the INSERT statement, check the table and column names, and run it in phpMyAdmin or your SQL client.

Example

Input

table: students
[{"name":"Aman","course":"PHP","score":82,"active":true},{"name":"Simran","course":"Excel","score":91,"active":false}]

Output

INSERT INTO `students` (`name`, `course`, `score`, `active`) VALUES
('Aman', 'PHP', 82, 1),
('Simran', 'Excel', 91, 0);

Common uses

  • Loading sample data from an API or a spreadsheet export into a development database.
  • Creating seed files for a new table.
  • Producing import statements for a WordPress custom table.

Privacy and safety

This tool runs in your browser. The text you enter is processed on your device and is not sent to NHP Learning.

Frequently asked questions

Is the generated SQL safe to run on a live database?

Review it first. Escaping prevents broken quotes, but the tool cannot know your table design. Test on a copy of the database and use prepared statements in application code.

Does it work for PostgreSQL or SQLite?

It is written for MySQL and MariaDB, which use backticks for names and backslash escapes in strings. Other databases need small changes.

What if my objects have different keys?

The columns are taken from the first object. Missing keys in later objects are written as NULL.

Learn to build this yourself

Free tutorials and courses on NHP Learning cover PHP, JavaScript, SQL and WordPress, from the basics to real projects.