Convert CSV to SQL INSERT statements and a CREATE TABLE for PostgreSQL, MySQL, SQLite or SQL Server, types read from every row
Paste a CSV and get a CREATE TABLE with types read from every row, then INSERT statements for your database.
How to use it
Paste the CSV, or open a .csv or .tsv file. Pick your database, name the table, and choose what goes before the INSERTs. Copy the SQL or download it as a .sql file.
Examples
A spreadsheet export into PostgreSQL
id,name,zip,active 1,"Lovelace, Ada",02134,true 2,Grace O'Hara,10001,false
CREATE TABLE "customers" (
"id" INTEGER NOT NULL,
"name" TEXT NOT NULL,
"zip" TEXT NOT NULL,
"active" BOOLEAN NOT NULL
);
INSERT INTO "customers" ("id", "name", "zip", "active") VALUES
(1, 'Lovelace, Ada', '02134', TRUE),
(2, 'Grace O''Hara', '10001', FALSE);The quoted comma stays in the name, the apostrophe is doubled, and the zip keeps its leading zero as text.
The same rows for SQL Server
id,name,zip,active 1,"Lovelace, Ada",02134,true 2,Grace O'Hara,10001,false
CREATE TABLE [customers] ( [id] INT NOT NULL, [name] NVARCHAR(255) NOT NULL, [zip] NVARCHAR(255) NOT NULL, [active] BIT NOT NULL ); INSERT INTO [customers] ([id], [name], [zip], [active]) VALUES (1, N'Lovelace, Ada', N'02134', 1), (2, N'Grace O''Hara', N'10001', 0);
Brackets around names, N'…' for text, and BIT with 1 and 0 for the booleans.
How column types are chosen
| Values | PostgreSQL | MySQL | SQLite | SQL Server |
|---|---|---|---|---|
42, -7 | INTEGER | INT | INTEGER | INT |
9007199254740993 | BIGINT | BIGINT | INTEGER | BIGINT |
1250.50 | NUMERIC | DECIMAL(6, 2) | NUMERIC | DECIMAL(6, 2) |
true, false | BOOLEAN | BOOLEAN | INTEGER (1, 0) | BIT (1, 0) |
2026-01-15 | DATE | DATE | TEXT | DATE |
2026-01-15 10:30:00 | TIMESTAMP | DATETIME | TEXT | DATETIME2 |
2026-01-15T10:30:00Z | TIMESTAMPTZ | VARCHAR(255) | TEXT | DATETIMEOFFSET |
Ada, 02134 | TEXT | VARCHAR(255) or TEXT | TEXT | NVARCHAR(255), (4000) or (MAX) |
What changes for each database
Questions
- My CSV has no header row. What are the columns called?
Turn Header row off and the first line is read as data; the columns are named column_1, column_2 and so on. Rename them in the CREATE TABLE, or add a header line to the CSV first. - What happens to empty cells?
With Empty as NULL on (the default), an empty cell is NULL. Off, an empty cell in a text column is an empty string, ''; in a number, date or boolean column it is still NULL, since '' is not a valid value there. - Which delimiter does it read?
Detect reads commas, semicolons, tabs and pipes from the first lines. Pick one when a file is ambiguous, for example a European export that uses semicolons between values and commas inside numbers. - How many rows should go in one INSERT?
One statement with many rows loads much faster than one statement per row. 100 is a safe default; 1000 is the most SQL Server takes. Choose 1 when you want one statement per line, for example to see exactly which row a database refuses. - Is my CSV uploaded?
No. Everything runs in your browser, so your text stays on your device. Nothing you paste is uploaded unless you share a result, which is locked with your password first.