CSV to SQL INSERT Generator
Convert CSV rows into SQL INSERT statements with a table name, optional header row, and correct quoting for text, numbers and escaped quotes.
Line endings, dates and numbers
INSERT INTO users (name, age, city) VALUES ('Ada', 36, 'London');
INSERT INTO users (name, age, city) VALUES ('Grace', 45, 'New York, NY');Turn CSV rows into SQL INSERT statements
Paste comma-, semicolon-, tab- or pipe-separated data (the Delimiter list also has colon, caret, space and Detect), type the target table name, and this tool builds one ready-to-run INSERT INTO ... VALUES (...); statement per row. Toggle First row is header to use your top row as the column names, or leave it off to get auto-named col1, col2, … columns. The output updates live as you type and copies with one click, so you can seed a database, write a migration, or load test data. Pick the Database — Standard SQL, PostgreSQL, MySQL / MariaDB, SQLite or SQL Server — to have names quoted the way it quotes them, and tick Include CREATE TABLE for a table definition with a type inferred for each column. Every setting is kept in the page address, so a reload keeps it and a bookmark or Copy link carries it; the table name goes only into the link Copy link makes, and the CSV, the Key column and the Column types choices stay on this page.
Correct quoting and escaping
Plain numbers such as 36 or -7 are emitted unquoted, while everything else is wrapped in single quotes like 'Ada'. Single quotes inside a value are escaped by doubling them, so O'Brien becomes 'O''Brien' instead of breaking your query. Quoted CSV fields keep commas and doubled quotes intact, values with leading zeros like 007 stay quoted so nothing is lost, and short rows are padded so every statement has a matching number of columns and values. An empty cell is written as '', or as NULL with Write empty cells as NULL ticked. Under the folded Line endings, dates and numbers section, the statements can be joined with CRLF for Windows instead of LF, dates in the data read day first or month first become ISO dates (so CREATE TABLE can type the column DATE), and numbers with a decimal comma, such as 1.234,56, are read as numbers. Rows with every cell empty are dropped by the conversion itself; to clean the table first, CSV Transpose turns rows into columns, Remove Duplicate Lines drops repeated rows, and the Text Case Converter changes the case of the text.
Frequently asked questions
How are numbers and text told apart?
A value that is a plain integer or decimal (optionally negative, with no leading zeros) is written unquoted, for example 36 or 3.14 — unless Include CREATE TABLE is on and Column types sets its column to TEXT. Everything else — text, dates and values with leading zeros like 007 — is wrapped in single quotes so it is stored exactly as typed. An empty cell is written as '' unless Write empty cells as NULL is ticked; with Include CREATE TABLE on, an empty cell in a number, date or true/false column is NULL either way, since '' is not a value of that type.
What happens to single quotes and commas inside values?
Single quotes are escaped by doubling them following standard SQL string rules, so O'Brien becomes 'O''Brien'. Commas inside a value are preserved as long as the field is wrapped in double quotes in your CSV, exactly like a normal spreadsheet export.
What types does CREATE TABLE use, and can it write one INSERT for many rows?
With Include CREATE TABLE ticked, each column gets the first type every value in it fits, unless you pick another under Column types: BOOLEAN, INTEGER, BIGINT for whole numbers too large for a 32-bit INTEGER, DECIMAL, DATE, or else TEXT — spelled BIT and NVARCHAR(MAX) on SQL Server, with DECIMAL sized to the data on MySQL and SQL Server. Add DROP TABLE IF EXISTS and Use CREATE TABLE IF NOT EXISTS make the script safe to run again. A batching option writes a single INSERT with many VALUES rows instead of one statement per row, starting a new statement each time a batch fills — SQL Server's limit for one VALUES list.
Can it write UPDATE or DELETE statements, give the table a primary key, or tidy the input first?
Yes. “Write” switches from INSERT to UPDATE (by key), which sets every other column where the key matches, or DELETE (by key); pick the “Key column” from the header’s columns, and until you do the page asks for one. The same Key column becomes the table’s PRIMARY KEY in the CREATE TABLE, with a text key given a length-limited VARCHAR on MySQL and NVARCHAR on SQL Server, which cannot index TEXT. “Skip lines at the top” drops a banner above the header, “Convert at most this many rows” stops early, and “Tidy column names” turns spaces into _ and takes accents off. The Delimiter list adds pipe, colon, caret and space, and Detect guesses the separator.
Can it write Windows line endings, or read European numbers and day-first dates?
Yes, in the folded Line endings, dates and numbers section. “Line endings” switches from LF to CRLF between the statements, for a script opened on Windows; a line break inside a quoted value is the data's own and stays as it is. “Dates in the data” reads day-first or month-first dates as ISO dates, so CREATE TABLE can type the column DATE, and a date that does not exist is left as written. “Numbers use a decimal comma” reads 1.234,56 as the number 1234.56. Each starts off, so the output is unchanged until you pick it.