CSV to SQL
Generate SQL INSERT statements (and an optional CREATE TABLE) from CSV, with numbers and NULLs detected.
Paste or drop
Paste text below, or drop a file instead.
Choose an output
Generate SQL INSERT statements (and an optional CREATE TABLE) from CSV, with numbers and NULLs detected.
Fine-tune
Optional — sensible defaults are already set.
About CSV to SQL
This tool generates SQL INSERT statements from a CSV file, with an optional CREATE TABLE statement to set up the table first. Columns that hold only plain numbers are written unquoted, empty cells become NULL and text is quoted with single quotes escaped. It is a quick way to move spreadsheet data into a database when you don't have an import wizard.
When it helps
- Seeding a development database with sample data kept in a spreadsheet.
- Writing a migration that inserts lookup values such as countries, categories or plans.
- Loading a CSV into SQLite, PostgreSQL, MySQL or SQL Server through a plain SQL console.
Tips
- Match "Identifier quoting" to your database: double quotes for PostgreSQL and SQLite, backticks for MySQL and MariaDB, square brackets for SQL Server.
- Raise "Rows per INSERT" to a few hundred for large files. Multi-row inserts run much faster than one statement per row.
- CREATE TABLE guesses INTEGER, NUMERIC or TEXT for each column. Review the types before running it, especially for dates, which come out as TEXT.
- Values with leading zeros or thousands separators, such as ZIP codes or 1,200, are treated as text, which keeps them intact.
Good to know
Quick answers about csv to sql in your browser.
A column is numeric only if every non-empty value is a plain integer or decimal, such as 42, -3 or 19.99. One text value in the column makes the whole column quoted text.
Turn off "First row is a header" and the columns are named column1, column2 and so on. Rename them in the SQL, or add a header row to the CSV first.
Yes. There is no sign-up, no watermark and no limit on how many files you process.
No. Files are read and processed locally in your browser, so they never leave your device.
Related tools
Part of the CSV Tools collection.