Xerobit

SQL Insert Generator for Building INSERT Statements

This sql insert generator builds standard INSERT INTO statements from a table name and rows of values you provide. Enter your columns once, add as many rows as needed, and copy the resulting SQL. The tool uses a hand-written tokenizer to handle quoted strings, numbers and identifiers safely, and it runs entirely in your browser so nothing is uploaded.

Use single quotes for strings, NULL for missing values, true/false for booleans. Double a single quote inside a string to escape it.

Append a semicolon at the end of each statement

Generated SQL

INSERT INTO users (id, name, email, active) VALUES (1, 'Alice', 'alice@example.com', TRUE);
INSERT INTO users (id, name, email, active) VALUES (2, 'Bob', 'bob@example.com', FALSE);
INSERT INTO users (id, name, email, active) VALUES (3, NULL, NULL, NULL);

How to use the sql insert generator

  1. Enter the table name in the first field. You can include a schema prefix like dbo.users.
  2. Type the column names separated by commas. These will appear in the parentheses after the table name.
  3. Add your data rows in the text area, one row per line. Separate values with commas and use single quotes around strings.
  4. Toggle Add semicolons if your database client requires them at the end of each statement.
  5. Copy the generated SQL from the output box and run it in your database.

How the SQL Insert Generator Works

The sql insert generator takes three inputs: a table name, a list of columns, and one or more rows of values. For each row it produces a standard INSERT INTO table (col1, col2) VALUES (val1, val2); statement.

Before assembling the statement, the tool passes every value through a hand-written tokenizer. This tokenizer reads character by character and classifies input into distinct types: single-quoted strings (where two consecutive single quotes represent an escaped quote), double-quoted identifiers, numeric literals including decimals and negative signs, the keywords NULL, TRUE and FALSE, unquoted identifiers, operators, and comments. Line comments starting with -- and block comments wrapped in /* */ are stripped out before parsing.

For example, given the table orders, columns id, total and a row 42, 19.99, the generator outputs:

INSERT INTO orders (id, total) VALUES (42, 19.99);

Supported Value Types

The tokenizer recognizes several common SQL literal types so you do not need to manually format everything:

TypeExample InputOutput in SQL
String'hello''hello'
Escaped string'it''s''it''s'
Integer4242
Decimal-3.14-3.14
BooleantrueTRUE
NullnullNULL
Function callNOW()NOW()
Typed literalDATE '2020-01-01'DATE '2020-01-01'

Function calls such as NOW(), keywords such as CURRENT_TIMESTAMP and typed literals such as DATE '2020-01-01' are passed through. Anything else, including unquoted text like Alice, a double-quoted value or a semicolon, is rejected with an error so broken or injected SQL never reaches your database. Table and column names must be plain, schema.table, or quoted with double quotes, backticks or square brackets.

Handling Quotes and Special Characters

In SQL, strings are enclosed in single quotes. If your string contains a single quote, you must double it. The sql insert generator preserves doubled quotes exactly as you type them. For instance, to insert the name O'Brien, write 'O''Brien' in the rows field. The tokenizer reads the two consecutive single quotes as an escaped character rather than the end of the string.

Double-quoted identifiers follow a similar rule. If a column or table name contains spaces or reserved words, wrap it in double quotes: "First Name". Inside a double-quoted identifier, two consecutive double quotes represent a literal double quote character.

If you need to generate inserts from structured tabular data rather than typing values manually, consider using the csv to sql insert tool, which converts CSV rows directly into INSERT statements.

Limitations of the Tokenizer

This tool uses a hand-written, dialect-agnostic tokenizer rather than a full SQL parser. It handles the most common cases well but has deliberate limits:

  • It does not validate whether column names exist in any real schema.
  • Complex expressions involving nested parentheses, subqueries, or CTEs may not tokenize correctly.
  • Dialect-specific syntax such as MySQL backtick identifiers, PostgreSQL dollar-quoted strings, or SQL Server bracket identifiers are not fully supported. Dollar-quoted strings will be treated as operators and identifiers.
  • Multi-byte Unicode characters inside strings are preserved, but the tokenizer operates on code units, so surrogate pairs are not specially validated.

For formatting or validating existing SQL, use the sql formatter or sql minify tools instead.

Practical Use Cases

Developers frequently need to generate seed data for local databases, create migration scripts, or reproduce bug reports with specific rows. Typing INSERT statements by hand becomes tedious beyond a few rows. This sql insert generator speeds up that workflow by letting you paste rows of values and instantly receiving syntactically correct statements.

When building test fixtures, you might combine this tool with a fake name generator to produce realistic sample data. Generate the names, paste them as string values into the rows field, and get ready-to-run SQL.

If you later need to extract data back out of SQL or convert it to another format, tools like sql to json or sql to csv can help reverse the process.

Worked examples

ExampleInputResult
Simple users tableTable name: users; Columns (comma-separated): id, name, email; Rows (one per line, values comma-separated): 1, 'Alice', 'alice@example.com' / 2, 'Bob', 'bob@example.com'; Add semicolons: yesINSERT INTO users (id, name, email) VALUES (1, 'Alice', 'alice@example.com'); / INSERT INTO users (id, name, email) VALUES (2, 'Bob', 'bob@example.com');
With NULLs and booleansTable name: products; Columns (comma-separated): sku, price, available; Rows (one per line, values comma-separated): 'A-01', 9.99, true / 'A-02', NULL, false; Add semicolons: yesINSERT INTO products (sku, price, available) VALUES ('A-01', 9.99, TRUE); / INSERT INTO products (sku, price, available) VALUES ('A-02', NULL, FALSE);
Escaped quotes in stringsTable name: notes; Columns (comma-separated): id, text; Rows (one per line, values comma-separated): 1, 'It''s working' / 2, 'She said ''hello'''; Add semicolons: noINSERT INTO notes (id, text) VALUES (1, 'It''s working') / INSERT INTO notes (id, text) VALUES (2, 'She said ''hello''')

FAQ

Does this sql insert generator support multiple rows?

Yes. Enter one row per line in the text area. The tool generates a separate INSERT statement for each line. Some databases support multi-row VALUES syntax, but individual statements are universally compatible.

How do I include a single quote inside a string value?

Double the single quote. Write 'O''Brien' instead of 'O'Brien'. The tokenizer recognizes two consecutive single quotes as an escaped quote within a string literal.

Can I use NULL values?

Yes. Type NULL (without quotes) in the position where you want a null value. The generator outputs the unquoted NULL keyword in the SQL statement.

Is my data sent to a server?

No. The sql insert generator processes everything locally in your browser using JavaScript. No data is transmitted over the network.

What happens if my number of values does not match my columns?

The tool checks each row against the column count. If a row has too many or too few values, it returns an error message indicating which row failed validation.

Does it support MySQL, PostgreSQL and SQL Server?

It generates standard ANSI SQL INSERT statements that work across all major relational databases. Backtick, double-quote and bracket quoting are accepted for table and column names.