Account

What new tool do you want?

Developer Tools

CSV to SQL INSERT Generator

Generate SQL CREATE TABLE and INSERT statements from CSV data for MySQL, PostgreSQL, SQLite or SQL Server.

How to use

  1. 1Paste CSV with a header row.
  2. 2Set the table name and dialect, then copy the SQL.

Frequently asked questions

How are column types chosen?

Each column is checked: all integers become INTEGER, all numbers DECIMAL/REAL, true/false BOOLEAN, everything else text.

Are quotes in values escaped?

Yes. Single quotes are doubled (O'Brien → 'O''Brien'), which is the SQL standard escape.

How are empty cells stored?

Empty cells become NULL rather than an empty string.

Column types are inferred by checking every value, not sampling

For each column, the type-inference step collects every non-empty value in that column and only assigns INTEGER if literally all of them match `^-?\d+$`, only DECIMAL/REAL if all match a decimal pattern, only BOOLEAN if all are true/false — any single value that breaks the pattern falls the whole column back to TEXT (or NVARCHAR(MAX) for SQL Server). This is deliberately conservative: a column that's 999 clean integers and one stray 'N/A' becomes TEXT rather than INTEGER, which avoids generating a CREATE TABLE that would reject real rows on import, at the cost of sometimes under-typing a column you know is numeric (safe to hand-edit the generated DDL in that case).

Dialect choice changes identifier quoting and the escape style, not just keywords

Switching dialects changes how column and table names are quoted — double quotes for PostgreSQL/SQLite, backticks for MySQL/MariaDB, square brackets for SQL Server — which matters the moment a column name collides with a reserved word (`order`, `group`) or contains a space. It also changes string literal prefixing: SQL Server strings get an `N` prefix (`N'text'`) for Unicode correctness, which the other three dialects don't use. Single quotes inside values are escaped by doubling them everywhere (`O'Brien` → `'O''Brien'`), which is the ANSI SQL standard and works across all four dialects.

Batch insert vs. one-statement-per-row is a real trade-off

With 'One INSERT for all rows' on, every row becomes a tuple in a single multi-row `INSERT INTO ... VALUES (...), (...), (...)` statement, which is dramatically faster to execute than one `INSERT` per row when you're loading thousands of records, since most databases parse and plan each statement separately. Turn it off when you specifically want per-row statements — for example, when hand-reviewing a small seed-data diff in version control, where one row per line in the diff is easier to read than one giant multi-line statement.

Worked example: CSV to SQL INSERT Generator

CSV `id,name,score\n1,O'Brien,9.5\n2,,7` with table name `people` and PostgreSQL selected generates: CREATE TABLE "people" ( "id" INTEGER, "name" TEXT, "score" DECIMAL(18,6) ); INSERT INTO "people" ("id", "name", "score") VALUES (1, 'O''Brien', 9.5), (2, NULL, 7); The apostrophe in O'Brien is doubled to stay valid SQL, and the empty `name` cell in row 2 becomes `NULL` rather than an empty string — both exactly what you'd want for a real import.

A blank table name becomes my_table, and empty cells skip the type check

An empty paste produces an empty result, not a create statement. Table name opens on my_table, and if I clear it the name falls back to my_table. The name is quoted for the dialect. PostgreSQL and SQLite use double quotes and double any quote inside the name. MySQL uses backticks. SQL Server uses square brackets. Dialect opens on PostgreSQL. Include CREATE TABLE and One INSERT for all rows both start on. When the column type is chosen, empty cells are ignored, so a column of whole numbers with a few blanks can still be an integer. A column with any non-integer value is not forced into that integer type. The download uses an sql name.

Related tools

More: Developer Tools