How to use the CSV & Excel to SQL
- Paste CSV or copied Excel cells, open a
.csv/.xlsxfile, or click Load sample. - Pick your database dialect and enter the table name.
- Choose the statements you need:
CREATE TABLEwith detected types,DROP TABLE, a transaction, and how many rows go in eachINSERT. - Check the detected column types in the preview, then Copy or Download .sql and run it in your database client.
What is a CSV to SQL converter?
A CSV to SQL converter turns rows of a spreadsheet into SQL statements a database can execute: a CREATE TABLE statement that defines the columns, and INSERT INTO … VALUES statements that add the data. It is the quickest way to load a one-off export, seed a development database or move data from Excel into MySQL or PostgreSQL without an import wizard.
CREATE TABLE `customers` (
`id` INT NOT NULL,
`name` VARCHAR(16),
`signup_date` DATE,
`monthly_spend` DECIMAL(10,2),
PRIMARY KEY (`id`)
);
INSERT INTO `customers` (`id`, `name`, `signup_date`, `monthly_spend`) VALUES
(1, 'Ada Lovelace', '2024-01-15', 49),
(4, 'O''Brien, Pat', '2024-04-09', 49);
How column types are detected
Every value in a column is checked and the narrowest type that fits all of them is chosen. The preview shows the result as a badge above each column.
| Values in the column | MySQL | PostgreSQL | SQL Server |
|---|---|---|---|
| Whole numbers | INT / BIGINT | INTEGER / BIGINT | INT / BIGINT |
| Decimals | DECIMAL(p,s) | NUMERIC(p,s) | DECIMAL(p,s) |
| true / false | TINYINT(1) | BOOLEAN | BIT |
2024-01-15 | DATE | DATE | DATE |
2024-01-15 14:30:00 | DATETIME | TIMESTAMP | DATETIME2 |
| Text | VARCHAR(n) / TEXT | VARCHAR(n) / TEXT | NVARCHAR(n) / NVARCHAR(MAX) |
Text columns get a VARCHAR length rounded up from the longest value (16, 32, 50, 100, 255…). Review the lengths before loading production data — a column that is short in your sample may hold longer values later.
Escaping and dialect differences
- Quotes inside text are doubled (
O'Brien→'O''Brien'); MySQL output also escapes backslashes. - Identifiers are quoted with backticks (MySQL), double quotes (PostgreSQL, SQLite, Oracle) or brackets (SQL Server), so reserved words like
orderorgroupwork as column names. - Multi-row inserts are much faster than one statement per row. SQL Server allows at most 1,000 rows per
VALUESlist, and Oracle usesINSERT ALL … SELECT 1 FROM DUAL. - Empty cells become
NULLby default; untick the option to insert empty strings.
Tips for large imports
Wrap the inserts in a transaction so a failed row does not leave half the data behind, and use batches of 500–1,000 rows. For millions of rows, native bulk loaders such as MySQL LOAD DATA INFILE or PostgreSQL COPY are faster still. Have JSON instead? Use JSON to SQL, and design a table by hand with the CREATE TABLE generator. Tidy the result with the SQL Formatter.
Tools that pair well with the CSV & Excel to SQL
- SQL to JSON, CSV & Excel — Paste a SQL dump or a few INSERT statements and get the rows back as JSON, CSV or an Excel workbook with one sheet per table.
- Excel to JSON — Open an .xlsx workbook or paste cells straight from Excel or Google Sheets and get clean JSON.
- JSON to Excel — Turn a JSON array into a real Excel workbook.
- CSV & Excel to HTML Table — Paste spreadsheet cells, CSV or JSON and get semantic, escaped HTML table markup — with an optional ready-made style and a live preview.
Frequently asked questions
How do I convert an Excel sheet to SQL INSERT statements?
Which databases are supported?
Can I get one INSERT statement per row?
Why are my column names changed?
signup_date, which avoids quoting problems. Untick it to keep the original header text.