01What is SQL INSERT Generator?
Typing INSERT statements by hand goes wrong in small, annoying ways. A stray apostrophe in a surname breaks the whole script, or a ZIP code loses its leading zero. SQL INSERT Generator builds the statements for you from a small grid of rows. You start with a table name and a list of columns. Each column gets a name, one of nine types (VARCHAR, INT, BIGINT, DECIMAL, BOOLEAN, TEXT, DATE, TIMESTAMP or UUID), a nullable flag, a primary-key flag and an optional default. Then you type rows into the grid or paste CSV. The CSV parser follows the usual RFC 4180 rules, so quoted fields can hold commas, line breaks and doubled quotes. Imported rows are appended to the rows already in the grid. Values are formatted by column type. In INT, BIGINT and DECIMAL columns, anything that looks like a number (including 1e3) is written bare. Everything else becomes a single-quoted string literal with apostrophes doubled, which is the standard SQL rule. MySQL gets one extra step. Its default mode treats a backslash inside a string as an escape, so the tool doubles backslashes for MySQL only. BOOLEAN cells accept true, false, 1 and 0 and come out as TRUE/FALSE for PostgreSQL and 1/0 for MySQL and SQLite. Names are left bare when they are simple. A name with spaces or odd characters, or one on a short list of common reserved words such as order or user, gets quoted: backticks for MySQL, double quotes for PostgreSQL and SQLite. Here is a quick example. With the default users table on MySQL, a row of 1, O'Brien and an empty email produces (1, 'O''Brien', NULL) inside a multi-row INSERT. You can switch to one statement per row and add a CREATE TABLE in front. That CREATE TABLE maps a few types per dialect. MySQL gets TINYINT(1) for BOOLEAN, CHAR(36) for UUID and DECIMAL(10,2) for DECIMAL, and SQLite stores UUID as TEXT. Now the limits. An empty cell, or the word null, becomes NULL in a nullable column. In a NOT NULL column it takes the column Default if you set one. With no Default it is still NULL, and the database will reject that row. A non-numeric value in a number column is quoted rather than flagged. The reserved-word list is short, so pick Always quote names if you are unsure. The output stays in the page until you copy it or download insert.sql.
Backend developers and QA engineers who need a handful of correctly escaped INSERT rows for a seed script, test fixture or bug report. The tool runs entirely in your browser, so your data never leaves your device.
02How to use SQL INSERT Generator
- Type the table name in the Table box (schema.table is quoted part by part) and choose MySQL, PostgreSQL or SQLite under Dialect
- In Columns, set each column's Name, Type, Nullable, PK and Default, and use Add Column for more
- Fill the Data Rows grid with Add Row, or click Import CSV, paste your lines and press Import Rows
- Tick Multi-row INSERT and Include CREATE TABLE as you need, and pick Quote names if needed or Always quote names under Identifiers
- Read the Generated SQL panel, then use Copy or Download to save it as insert.sql
03Worked examples
- Input:
Default columns id INT, name VARCHAR, email VARCHAR (nullable); MySQL, multi-row; rows: 1,O'Brien,(empty) and 2,Ana,[email protected] - Result:
INSERT INTO users (id, name, email) VALUES (1, 'O''Brien', NULL), (2, 'Ana', '[email protected]'); - The apostrophe is doubled, and the empty cell becomes NULL.
- Input:
Row 1, C:\temp, null; single-row inserts; MySQL vs PostgreSQL - Result:
MySQL: INSERT INTO users (id, name, email) VALUES (1, 'C:\\temp', NULL); PostgreSQL: INSERT INTO users (id, name, email) VALUES (1, 'C:\temp', NULL); - MySQL treats a backslash as an escape character by default, so the tool doubles it for MySQL only.
- Input:
Create table on, MySQL, table shop.items; columns order INT PK, active BOOLEAN, price DECIMAL, zip VARCHAR (nullable); rows 7,true,19.90,02134 and 8,0,1e3,(empty) - Result:
CREATE TABLE shop.items ( `order` INT NOT NULL, active TINYINT(1) NOT NULL, price DECIMAL(10,2) NOT NULL, zip VARCHAR(255), PRIMARY KEY (`order`) ); INSERT INTO shop.items (`order`, active, price, zip) VALUES (7, 1, 19.90, '02134'), (8, 0, 1e3, NULL); - The reserved word order is quoted with backticks, BOOLEAN becomes TINYINT(1), and the ZIP column is VARCHAR, so its leading zero is kept.
- Input:
Same columns, PostgreSQL, table items; row 7,true,abc,02134 - Result:
INSERT INTO items ("order", active, price, zip) VALUES (7, TRUE, 'abc', '02134'); - PostgreSQL uses double-quoted identifiers and TRUE. A non-numeric value in a DECIMAL column becomes a quoted string, which the database then rejects.
- Input:
CSV import, SQLite, Always quote names; pasted lines: 3,"Smith, Jane","a""[email protected]" and 4,"multi(newline)line", - Result:
INSERT INTO "users" ("id", "name", "email") VALUES (3, 'Smith, Jane', 'a"[email protected]'), (4, 'multi line', NULL); - The quoted comma stays in the name, the doubled quote becomes one quote, and the line break inside quotes is kept in the string.
- Input:
Default columns with name Default set to anon, MySQL; row 5, (empty), (empty) - Result:
INSERT INTO users (id, name, email) VALUES (5, 'anon', NULL); - name is not nullable, so the empty cell takes its Default. The nullable email column gets NULL.
04Common use cases
- Turning a dozen rows from a spreadsheet export into a seed script for a local MySQL or PostgreSQL database
- Writing fixture INSERTs for an integration test that runs against SQLite
- Escaping customer names with apostrophes or Windows paths with backslashes without hand-editing quotes
- Drafting a CREATE TABLE plus sample rows to attach to a bug report or a Stack Overflow question
- Checking how the same row differs between MySQL and PostgreSQL output before porting a seed file
- Building a table with a reserved column name such as order or user and seeing how each dialect quotes it
05Tips
- Import CSV does not detect a header line. Delete the header before pasting, or remove that extra row from the grid afterwards.
- Give NOT NULL columns a Default. Blank cells in them then get that value instead of NULL.
- Keep ZIP codes, phone numbers and IDs with leading zeros in a VARCHAR column. An INT column writes 02134 bare, and the database stores 2134.
- If you paste Windows paths or regex patterns for MySQL, check the doubled backslashes are what you want. They are correct for MySQL's default mode but wrong if NO_BACKSLASH_ESCAPES is on.
- Very large multi-row INSERTs can hit MySQL's max_allowed_packet limit. Split big batches into several statements.
06Related concepts
Bulk insert, String literal escaping, Quoted identifiers, CSV, Seed data.
Frequently Asked Questions
What is SQL INSERT Generator?
SQL INSERT Generator is a free, browser-based developer tool on AIDToolStack. Generate SQL INSERT statements from column definitions with CSV import. It requires no installation or sign-up and works entirely in your browser.
Is SQL INSERT Generator free to use?
Yes. No sign-up, no fees and no usage cap.
Does SQL INSERT Generator store my data?
No. It runs in your browser; nothing is uploaded.