CSV to SQL converter with column types
The converter reads the header row for column names and checks every value to pick a type, then writes a CREATE TABLE in the dialect you choose. Headers are turned into snake_case (Product Name becomes product_name), empty or repeated headers get names like column_3 or name_2, and names longer than the database allows are shortened. Choose As in header under More options to keep the original names.
Columns with no empty cells get NOT NULL, and a column named id with unique values becomes the primary key. The Columns table shows the first rows under each column so you can confirm the delimiter and types before copying.
- Whole numbers: INTEGER or BIGINT (INT in MySQL and SQL Server)
- Decimals: NUMERIC(p,s) in PostgreSQL, DECIMAL(p,s) in MySQL and SQL Server
- true/false, yes/no: BOOLEAN, TINYINT(1) in MySQL, BIT in SQL Server
- YYYY-MM-DD: DATE
- ISO date-times: TIMESTAMP, DATETIME in MySQL, DATETIME2 in SQL Server, with TIMESTAMPTZ or DATETIMEOFFSET when values include a time zone
- Anything else: TEXT in PostgreSQL and SQLite, VARCHAR(n) in MySQL, NVARCHAR(n) in SQL Server
CSV to SQL INSERT statements
Rows are written as multi-row INSERT statements with 100 rows each. Under More options you can write one INSERT per row or up to 1,000 rows per statement, add DROP TABLE IF EXISTS before the CREATE TABLE, and wrap the inserts in a transaction. Empty cells, and cells that contain NULL or \N, become NULL; turn that off to insert empty strings instead.
Switch Statements to Upsert to update rows that already exist. The key column decides what counts as the same row, and the statement follows the dialect: ON CONFLICT DO UPDATE for PostgreSQL and SQLite, ON DUPLICATE KEY UPDATE for MySQL, and MERGE for SQL Server. If the key column repeats a value, a note points to the line, since the database would reject it.
CSV to MySQL and MariaDB
With MySQL / MariaDB selected, names are quoted with backticks and text values escape backslashes and line breaks the way MySQL expects. Text columns up to 255 characters become VARCHAR sized to fit the longest value, longer ones TEXT, and booleans become TINYINT(1) with TRUE and FALSE values. Date-times with a time zone, like 2024-05-01T09:00:00Z or +02:00, are converted to UTC and written without the offset, because DATETIME stores no zone and MariaDB rejects offsets. Values with fractional seconds get DATETIME(n) so the fractions are kept.
For very large files, MySQL's LOAD DATA LOCAL INFILE is faster than running INSERT statements. You can still use this tool to get the CREATE TABLE with the right types, then load the CSV into that table.
SQL to CSV: turn INSERT statements into a CSV file
Use the SQL to CSV switch at the top to go the other way. Paste a dump or a few INSERT statements and the rows come out as CSV with a header row. Quoted strings with doubled quotes, N'...' and E'...' strings, negative numbers and NULL are decoded, and comments, SET statements and ON CONFLICT clauses are skipped. Expressions such as NOW() or CAST(...) are kept as written.
Values that contain commas, quotes or line breaks are quoted in the CSV, and you can pick a comma, semicolon, tab or pipe as the delimiter. The download is named after the table, for example customers.csv.

