CSV to SQL
Turn a CSV file into SQL: a CREATE TABLE statement with inferred column types and INSERT statements for MySQL, PostgreSQL, SQL Server or SQLite.
INPUT
OUTPUT
Runs entirely in your browser. Nothing you enter is sent to a server.
How to convert CSV to SQL
Paste the CSV
Paste data with a header row or open a .csv file. The header becomes the column names.
Pick the database
Choose your database and the table name. Quoting and types follow its syntax.
Run the script
Copy or download the SQL and run it in your database client.
Column types from your data
Each column gets the narrowest type that fits every value: whole numbers become INTEGER or BIGINT, decimals become DECIMAL, ISO dates become DATE, and everything else becomes text sized to the longest value.
Safe values
Text values are quoted and single quotes inside them are doubled, so names such as O'Brien don't break the statement. Rows are grouped into multi-row INSERTs, which load much faster than one statement per row.
Frequently asked questions
Should I check the column types?
Yes. Types are inferred from the rows you paste. If a column holds IDs that look like numbers but may contain letters later, change it to text before running the script.
What happens to empty cells?
With Empty cells as NULL turned on they become NULL; otherwise they become empty text.
Is my data uploaded?
No. The SQL is generated in your browser.