How to use the CSV to SQL Insert Generator
- 1. Paste your CSVPut column names in the first row.
- 2. Pick the databaseChoose the SQL style, table name and how many rows go in each INSERT.
- 3. Copy the scriptGenerate, check the guessed types and download the .sql file.
How values and types are handled
Each column's type is guessed from all of its values:
- All whole numbers →
INT, orBIGINTif any value is beyond ±2,147,483,647. - Numbers with decimals →
DECIMAL(p, s), sized from the longest number. - Dates written as YYYY-MM-DD →
DATE; true/false →BOOLEAN(BIT in SQL Server). - Anything else →
VARCHARof 50, 255 or 1000 characters, depending on the longest value.
Text is wrapped in single quotes and any single quote inside it is doubled, which is the standard SQL way to escape it. Empty cells become NULL unless you untick that option. Column names are quoted the right way for your database: backticks for MySQL, double quotes for PostgreSQL and SQLite, and square brackets for SQL Server.
Worked example
The sample has 3 employees with id, name, city, salary and joined date. For MySQL the tool reports 3 rows in 1 INSERT statement and these types: id INT, name and city VARCHAR(50), salary DECIMAL(7,2) (because of 62000.50), joined DATE. The name Meera O'Neil is written safely as 'Meera O''Neil'.
Batching matters for big files. 10,000 rows with 100 rows per INSERT become 100 statements, which runs much faster than 10,000 separate ones. SQL Server allows at most 1,000 rows in one VALUES list, so do not go above that there.
The guessed types are a starting point. Before running the script, add a PRIMARY KEY, mark required columns NOT NULL, and widen any VARCHAR that may get longer values later.
Frequently asked questions
Can I import the CSV directly instead?
Yes, with LOAD DATA in MySQL, COPY in PostgreSQL or BULK INSERT in SQL Server. Those need file access on the server; INSERT scripts work anywhere you can run SQL.
Why is a number column shown as VARCHAR?
At least one value in it is not a plain number, such as 1,200 with a comma or N/A. Clean those cells and generate again.
Is my data sent anywhere?
No. The SQL is built in your browser.
Is this converter free?
Yes, completely free. We ask for your name and WhatsApp number once when you generate your first script, then every Uncodemy tool works without the form.