Skip to content
Sealpaste

Delete all recent work?

This removes the 0 items saved in this browser. Your settings stay.

Stop saving recent work?

New work won't be saved in this browser. The 0 items already saved can stay or go.

CSV to SQL Converter

CSV

Paste CSV, or

CtrlV paste · Ctrl↵ run now

SQL
Ready
Ln 1, Col 1
Runs in your browser. Nothing you paste is uploaded unless you share it.

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

  1. Paste the CSV, or open a .csv or .tsv file.
  2. Pick your database, name the table, and choose what goes before the INSERTs.
  3. Copy the SQL or download it as a .sql file.

Examples

A spreadsheet export into PostgreSQL

Input
id,name,zip,active
1,"Lovelace, Ada",02134,true
2,Grace O'Hara,10001,false
Result
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

Input
id,name,zip,active
1,"Lovelace, Ada",02134,true
2,Grace O'Hara,10001,false
Result
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

Every row is read, not only the first few, and each column gets the narrowest type all of its values fit. One word in a column of numbers makes it text, so no INSERT fails halfway through a long file.

Numbers with a leading zero, like the zip code 02134 or an ID 007, stay text: as a number they would lose the zero. Whole numbers past 2,147,483,647 become BIGINT, and past BIGINT an exact DECIMAL or NUMERIC, so no digit is rounded.

A column with no empty cell is NOT NULL. True and false (any case) are booleans; 2026-01-15 is a date; 2026-01-15 10:30 or 2026-01-15T10:30:00Z is a timestamp, with its zone where the database has a type for one.

ValuesPostgreSQLMySQLSQLiteSQL Server
42, -7INTEGERINTINTEGERINT
9007199254740993BIGINTBIGINTINTEGERBIGINT
1250.50NUMERICDECIMAL(6, 2)NUMERICDECIMAL(6, 2)
true, falseBOOLEANBOOLEANINTEGER (1, 0)BIT (1, 0)
2026-01-15DATEDATETEXTDATE
2026-01-15 10:30:00TIMESTAMPDATETIMETEXTDATETIME2
2026-01-15T10:30:00ZTIMESTAMPTZVARCHAR(255)TEXTDATETIMEOFFSET
Ada, 02134TEXTVARCHAR(255) or TEXTTEXTNVARCHAR(255), (4000) or (MAX)

What changes for each database

Names are quoted the way each database reads them: "name" in PostgreSQL and SQLite, `name` in MySQL, [name] in SQL Server, so a header like order, user or first name works as a column name.

Text is put in single quotes with any quote inside doubled: O'Hara becomes 'O''Hara'. MySQL also reads a backslash as an escape by default, so for MySQL each backslash is doubled; SQL Server text gets the N prefix so accents and other scripts are kept.

SQL Server takes at most 1,000 rows in one INSERT … VALUES, so Rows per INSERT stops there for it. SQL Server has no CREATE TABLE IF NOT EXISTS: that choice writes IF OBJECT_ID(…) IS NULL before the CREATE TABLE.

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.

Related tools