CSV to SQL
Turn CSV into SQL: a CREATE TABLE with column types worked out from the data, and INSERT statements with quotes escaped safely.
CSV to SQL turns a CSV with a header row into SQL: a CREATE TABLE statement with column types worked out from the data, and INSERT statements with quotes escaped. Choose PostgreSQL and SQLite, MySQL or SQL Server style.
How are column types chosen?
Type inference
A column becomes INTEGER (or BIGINT) if every filled cell is a whole number, DECIMAL with the right precision if they are decimals, BOOLEAN for true and false, DATE for YYYY-MM-DD, and VARCHAR or TEXT otherwise.
Safe values
Single quotes in text are doubled, empty cells become NULL, and identifiers are quoted the way your database expects, so names with spaces work.
Why use CSV to SQL?
- Load a spreadsheet into a database. Get a script you can run in psql, the MySQL client, SQL Server Management Studio or a SQLite shell.
- Escaping done right. Names such as O'Neil, and backslashes in MySQL, are escaped so the script runs and the data arrives intact.
- Private. Your data is turned into SQL in this tab.
How to use CSV to SQL, step by step

- Paste the CSV into CSV to SQL. The first row must be the column names.
- Set the table name and database. Choose how many rows go in each INSERT; more is faster to load.
- Copy or download the script. Review the CREATE TABLE types, then run it.
Frequently asked questions
Can I trust the inferred types?
They fit the data you pasted. If a column will later hold longer text or other values, widen the type in the CREATE TABLE before running it.
Is there a primary key?
No. Add one to the CREATE TABLE if your table needs it.
How many rows per INSERT should I use?
One is the most compatible. A few hundred loads much faster. SQL Server accepts at most 1000 rows in one VALUES list.
Looking for the long version? The guides cover each of these jobs in depth.