CSV to SQL INSERT Generator

Turn a CSV file into SQL INSERT statements.

Ad placeholder (leaderboard)
Enjoying the tools? Go Pro for £4.99 (one-time) and remove all ads — forever, on this device. Remove ads — £4.99

This tool converts CSV data into SQL INSERT statements — one statement per data row — ready to run in psql, the MySQL client, SQLite or SQL Server. It is a fast way to load a spreadsheet or export into a database table without writing the INSERTs by hand or setting up an import tool.

How it works

The first row of the CSV is treated as the column names, and you supply the table name. Each following row becomes an INSERT INTO table (cols) VALUES (...) statement. An RFC 4180-aware parser handles quoted fields, embedded commas and doubled quotes. With type inference on, the tool emits appropriate SQL literals:

Cell valueSQL output
clean number (e.g. 42)42 (unquoted)
true / falseTRUE / FALSE
empty cell or “null”NULL
anything else'quoted string' (single quotes doubled)

Turn inference off to quote every value as a string.

Example

Given the CSV:

id,name,active
1,Ada,true
2,"Bao, Jr.",false

with table name users, it produces:

INSERT INTO users (id, name, active) VALUES (1, 'Ada', TRUE);
INSERT INTO users (id, name, active) VALUES (2, 'Bao, Jr.', FALSE);

Note the number stays unquoted, the booleans become TRUE/FALSE, and the comma inside “Bao, Jr.” is kept as part of the string.

Everything runs locally in your browser — nothing is uploaded, which makes it safe for confidential spreadsheets and exports.

Ad placeholder (rectangle)