CSV to SQL

Turn CSV rows into SQL INSERT statements. Paste data or choose a file, select your database, then copy or download the generated SQL. Conversion happens in your browser.

.csv, .tsv and .txt files up to 10 MB

Paste CSV or choose a local .csv or .tsv file. You can also drop a file here.

Values stay as text by default, preserving leading zeros. Turn on detection when the target columns use number or boolean types.

Your SQL preview will appear here.

How CSV becomes SQL

The first CSV row becomes column names by default. Each remaining row becomes values in an INSERT statement. You can include a CREATE TABLE statement, combine up to 500 rows per INSERT, and choose PostgreSQL, MySQL, SQLite or SQL Server quoting.

What happens to values

CSV inputSQL output
001'001' by default, so leading zeros survive. Turn on type detection only if the destination column expects a number.
O'Neil'O''Neil'. Apostrophes are escaped, and identifiers are quoted for the chosen database.
An empty field'' by default. Choose “Convert empty fields to NULL” when missing values should be SQL NULL.
A quoted field with a comma or line breakOne text value. The CSV parser keeps quoted fields together and decodes doubled quotes.

Auto detect checks comma, semicolon, tab and pipe separators. If the preview looks wrong, choose the separator explicitly. Blank and duplicate column names get unique names so the SQL remains usable. Type detection recognizes booleans and conservative integer or decimal values; dates stay text because date formats vary by database.

The full result is available through Copy SQL or Download .sql. The on-page SQL preview shows its beginning when output is long, and the table preview shows the first 100 rows and 30 columns. Large files can take longer on a phone. For MySQL, backslashes are escaped using its usual string syntax; review that output if your server uses NO_BACKSLASH_ESCAPES.