Skip to main content
Database & SQL Tools

SQL INSERT Generator

Generate a SQL INSERT statement from a table name, columns, and one or more rows of values, with proper escaping.

Enter a table name, columns, and one or more rows of values - this tool generates a properly escaped INSERT statement, supporting multiple rows in one statement.

For inserting data already in CSV or JSON form, see the CSV to SQL Converter or JSON to SQL Converter instead of retyping values here.

What Does This Tool Generate?

A SQL INSERT INTO table (columns) VALUES (...) statement - supporting either a single row or multiple rows in one statement, with values properly quoted and special characters escaped.

Why Use This Tool?

Manually escaping quotes inside string values, and getting the parenthesis/comma placement right across multiple rows, is easy to fumble by hand. This tool builds it correctly every time.

How to Use It

  1. Enter the table name and column names.
  2. Add one or more rows of values.
  3. Copy the generated INSERT statement.

Limitations

This generates the statement text only - it never connects to or runs anything against a real database.

Example

Table products, columns sku, name, price, and two rows produce:

INSERT INTO products (sku, name, price) VALUES
('A-100', 'Blue Mug', 249),
('B-200', 'Travel Bottle', 599);

A value like O'Brien is escaped as 'O''Brien', so the quote does not end the string early.

Tips

  • Batch rows: one INSERT with many rows is much faster than many single-row INSERTs. For thousands of rows, split into batches of a few hundred.
  • Use NULL, not an empty string, for missing values when the column allows NULL.
  • Dates should be in ISO format: '2026-09-20' or '2026-09-20 14:30:00'.
  • Upserts: to update existing rows instead of failing on duplicates, use ON DUPLICATE KEY UPDATE (MySQL) or ON CONFLICT ... DO UPDATE (PostgreSQL).

Important: In Application Code, Use Parameters

Generated INSERT statements are great for seed files, migrations and one-off fixes. In application code, never build SQL by joining strings with user input - use prepared statements or your framework's query builder to prevent SQL injection.

Have the data in a spreadsheet? The CSV to SQL Converter is faster. Create the table first with the SQL Table Generator.

Frequently Asked Questions

Yes. Add multiple rows and the generator creates a multi-row INSERT, which is faster than many single-row statements.

Use NULL without quotes. 'NULL' in quotes is the four-letter text "NULL", not an empty value.

No. In applications always use parameterised queries or your framework's query builder to prevent SQL injection. This tool is for scripts, seeds and one-off data.
Share this tool: