CSV to SQL INSERT statements
Paste CSV with a header row and a table name to get INSERT statements ready for MySQL, PostgreSQL, SQL Server or SQLite.
Loading the tool…
Processing and privacy: The result is calculated inside your browser and your data is not sent to any server.
How to use it
- Enter csv data, cell delimiter, table name, statement style, identifier quoting and leave numbers unquoted.
- The result appears straight away and updates as you edit.
- Copy the result, or copy a link that keeps the same values to share it.
How it is calculated
The first row gives the column names. Text goes between single quotes with any inner ' doubled (O''Brien). Numbers like 30 and 12.5 stay unquoted (except leading zeros like 007), and empty cells become NULL when that option is on.
Example
Inputs: Cell delimiter = Detect automatically, Table name = products, Statement style = One statement, many rows, Identifier quoting = None, Leave numbers unquoted = yes. Result: SQL statements: INSERT INTO products (product, price, qty) VALUES ('Tea', 12.5, 3), ('Coffee', 18, 2), ('Dates', 30, 1);; Data rows: 3; Columns: 3.
product,price,qty Tea,12.5,3 Coffee,18,2 Dates,30,1
INSERT INTO products (product, price, qty) VALUES
('Tea', 12.5, 3),
('Coffee', 18, 2),
('Dates', 30, 1);Limits and caveats
- No CREATE TABLE is generated, so the table must already exist with suitable columns.
- Only ' is escaped, as standard SQL requires. In MySQL with default settings, double any backslash \ in the text.
- Dates and booleans are written as quoted text.
Questions about this tool
When should I use one statement for many rows?
For fast bulk loading; MySQL, PostgreSQL, SQLite and SQL Server all accept it.
Why did 007 stay quoted?
A number with a leading zero is usually a code or phone number, and storing it as a number would drop the zeros.
Should I quote identifiers?
Yes, if column names contain spaces, Arabic letters or reserved words such as order.
