CSV to SQL Converter
About this tool
About CSV to SQL
Paste a CSV export or drop a .csv file and get SQL you can run straight away: a CREATE TABLE statement with a sensible type for every column, followed by multi-row INSERT statements. The converter reads the header row for column names, detects whether the file uses commas, semicolons, tabs or pipes, and looks at every value to choose INT, BIGINT, DECIMAL with the right precision, BOOLEAN, DATE, TIMESTAMP or VARCHAR. Values with leading zeros, such as postcodes and phone numbers, stay text so nothing is lost. Pick MySQL, PostgreSQL, SQLite or SQL Server and the output uses that database's identifier quoting, boolean literals and string escaping, including N'…' strings for SQL Server. You choose the table name, the primary key, the number of rows per INSERT, and whether to add DROP TABLE IF EXISTS, NOT NULL constraints or a transaction. Blank cells and markers like NULL or N/A become real NULLs. The file is read in your browser and never uploaded, so customer lists and internal exports stay on your computer.
Built and maintained by Abhi JainUpdated
How to Convert CSV to SQL
- 1
Add your CSV
Paste CSV into the left pane, drop a .csv file onto it, or click Sample. The first line must hold the column names.
- 2
Choose the database
Pick MySQL, PostgreSQL, SQLite or SQL Server and type a table name. Adjust Primary key and Rows per INSERT if needed.
- 3
Set the options
Turn CREATE TABLE, DROP IF EXISTS, NOT NULL, transaction or snake_case column names on or off.
- 4
Copy or download
Copy the SQL or download it as a .sql file and run it in your database client.
CSV to SQL: questions and answers
How are column types chosen?
Every value in a column is checked. Whole numbers become INT (or BIGINT above 2,147,483,647), decimals become DECIMAL with enough precision and scale for the largest value, true/false and yes/no become BOOLEAN, ISO dates like 2025-03-14 become DATE, and everything else becomes text. If a column mixes types, it falls back to text so no value is rejected.
Why do numbers like 00123 stay as text?
A leading zero means the value is an identifier such as a postcode, account number or phone number. Storing it as a number would drop the zeros, so the converter keeps it as text.
How many rows go in one INSERT statement?
100 by default. You can change Rows per INSERT. SQL Server accepts at most 1000 rows in a single INSERT … VALUES, so batches are capped at 1000 for that database.
How are empty cells handled?
Blank cells are inserted as NULL. With the NULL, N/A, NaN option on, those markers are NULL too. Columns with no empty values get NOT NULL if that option is on.
Can I import a very large CSV this way?
Files of tens of thousands of rows convert in a moment. For millions of rows, your database's bulk loader (LOAD DATA INFILE in MySQL, COPY in PostgreSQL, BULK INSERT in SQL Server) is faster than running INSERT statements.
Related Tools
- JSON to SQLConvert a JSON array of objects into CREATE TABLE and INSERT statements.
- SQL INSERT GeneratorType or paste rows into a grid and get INSERT statements for any major database.
- CSV to JSONConvert CSV to JSON objects, arrays or keyed maps with real numbers, booleans and nesting.
- CSV Viewer & EditorOpen, edit, sort, filter and search big CSV files like a spreadsheet, then export CSV, TSV or JSON.
- SQL IN Clause GeneratorTurn a pasted list into a quoted, deduplicated SQL IN (…) clause, split into chunks.