CSV to SQL

Generate CREATE TABLE and INSERT statements from CSV. Dialect-aware quoting and type inference.

Drop a file or click to browse

or paste data below

Need the reverse conversion? JSON to SQL

How CSV to SQL works

How column types are chosen

Each column is typed by looking at all of its non-empty values. If every value is a whole number the column is INTEGER; if every value is a number with an optional decimal part it is REAL (DOUBLE PRECISION in PostgreSQL). A column holding only true, false, 0, or 1 is BOOLEAN in PostgreSQL and INTEGER in MySQL and SQLite. Everything else is text.

Values with a leading zero, such as ZIP codes and SKUs, keep the column as text so 02134 is not stored as 2134. In MySQL a text column is VARCHAR sized to its longest value (up to 255 characters, then TEXT); review those lengths if more data will be inserted later. Other dialects use TEXT.

Names, quoting, and escaping

Column and table names are cleaned so they are valid identifiers: anything other than letters, digits, and underscores becomes _, and a name starting with a digit gets a col_ prefix. MySQL identifiers are quoted with backticks; PostgreSQL and SQLite use double quotes.

Text values are wrapped in single quotes, and any single quote inside a value is doubled, so O'Brien becomes 'O''Brien'. Numbers and booleans in numeric or boolean columns are written without quotes. Empty cells become NULL unless you turn on default values, which writes '', 0, or false depending on the column type.

Statement options

By default you get CREATE TABLE IF NOT EXISTS followed by one INSERT per row. One-per-row output is easy to read and keeps a single bad row from failing the whole batch. Switch on single INSERT to get one statement with many value rows, which loads much faster for large files. Very large single statements can exceed a server limit such as MySQL's max_allowed_packet, so split big files.

Your chosen table name, dialect, and options are saved in the page URL (never your data), so you can bookmark a configuration or share it with a teammate. Tab-separated input is detected automatically.

Example

zip stays TEXT because of its leading zero, price becomes DOUBLE PRECISION, and the apostrophe in O'Brien is escaped.

CSV input
id,name,zip,price,active
1,O'Brien,02134,24.50,true
2,Lee,10001,3,false
PostgreSQL output
CREATE TABLE IF NOT EXISTS "customers" (
  "id" INTEGER,
  "name" TEXT,
  "zip" TEXT,
  "price" DOUBLE PRECISION,
  "active" BOOLEAN
);

INSERT INTO "customers" ("id", "name", "zip", "price", "active") VALUES (1, 'O''Brien', '02134', 24.50, true);
INSERT INTO "customers" ("id", "name", "zip", "price", "active") VALUES (2, 'Lee', '10001', 3, false);

How to use CSV to SQL

  1. 1

    Paste CSV or TSV, or drop a file. The first row must hold column names.

  2. 2

    Set the table name and pick MySQL, PostgreSQL, or SQLite.

  3. 3

    Choose per-row or single INSERT, and whether to include CREATE TABLE.

  4. 4

    Review the inferred column types, then copy or download inserts.sql.

When to use it

One-off imports

Load a CSV export into a development or staging database when a GUI import wizard is not available.

Migration and seed scripts

Generate INSERT statements that can be checked into a repository alongside schema migrations.

CSV to SQL questions

Can I change a column's inferred type?

Not in the tool. Copy the output and edit the CREATE TABLE line, or create the table yourself and turn off the CREATE TABLE option so only INSERT statements are generated.

Are dates detected?

No. Dates are written as quoted text. Most databases convert ISO dates such as 2026-01-15 when inserting into a DATE column, so create the table with the date types you want and generate INSERTs only.

Is the output safe to run against my database?

Values are escaped for standard SQL string literals, but always run generated SQL in a transaction or on a copy first, and check row counts afterward.

My columns have spaces and symbols. What happens to them?

They are replaced with underscores, so 'Order Total ($)' becomes Order_Total____. Rename columns first with Column Tools if you want cleaner names.

Questions about privacy, file size, or accounts are answered on the FAQ page.

Other tools in the same category, starting with the reverse conversion

Search all tools