Turn a CSV file into SQL
Drop a CSV and get a CREATE TABLE and INSERT script for PostgreSQL, MySQL or SQLite, with column types read from every row.
- Free, no sign-up
- Nothing uploaded
- Download .sql
or drop it here · CSV, TSV or TXT
No file handy? Try one:
How it works
- Drop the file. The page detects the separator (comma, semicolon, tab or pipe), reads quoted values with commas and line breaks inside them, and takes column names from the first row, turned into
snake_case. - Every value is checked. A column becomes
BIGINTonly if every value is a whole number,NUMERIC(p,s)sized to the largest value,DATEorTIMESTAMPTZonly if every value is a real date. Codes with leading zeros stay text. Empty cells becomeNULL. - Pick the database. PostgreSQL gets
TEXT,BOOLEAN,JSONBandUUID; MySQL getsVARCHAR,DATETIMEin UTC and backtick quoting; SQLite gets ISO date text and 1/0 for true/false. Reserved words such asorderare quoted. - Download the script. One
CREATE TABLE, then multi-rowINSERTstatements inside one transaction. Run it withpsql -f,mysql <orsqlite3 <.
Questions
- Is my CSV file uploaded?
- No. The file is read inside your browser tab and the SQL is written there too. Only the optional AI step sends anything: a summary of each column (name, type, counts and, if you leave the box ticked, up to five example values), and only when you press its button. The rows of your file are never sent.
- How are the column types chosen?
- The page checks every value in a column and picks the most specific type that all of them fit: true/false, whole number, exact decimal, date, date and time, UUID, JSON, then text. Empty cells become NULL. Numbers that start with 0, such as ZIP codes, stay text so the zero is not lost.
- My file uses semicolons and decimal commas. Does that work?
- Yes. The separator is detected (comma, semicolon, tab or pipe). With semicolons or tabs, numbers written as 12,50 or 1.250,00 are read as decimals and written as 12.50 and 1250.00. Dates such as 15.04.2024 are read as day/month/year when the data shows it.
- How do I load the .sql file?
- PostgreSQL:
psql -d yourdb -f table.sql. MySQL:mysql yourdb < table.sql. SQLite:sqlite3 your.db < table.sql. Or paste it into any SQL editor. The script runs inside one transaction, so a failure leaves nothing half loaded. - What about an Excel file?
- In Excel or Google Sheets choose File, then Save as or Download, and pick CSV. Drop the .csv file here.
- How big a file can it take?
- Up to 50 MB. The page shows the first rows of the script; the download and Copy all contain every row.