Pulse Data Hub

Tools / CSV to SQL

CSV to SQL Converter

Turn a CSV file into a CREATE TABLE statement and INSERT statements for PostgreSQL, MySQL, SQLite or SQL Server. Column types are detected for you.

Free, no sign-up. Everything runs in your browser, so your data is never uploaded.

How to use it

  1. Paste a CSV with a header row, or open a file. The delimiter is detected automatically.
  2. Choose your database and a table name. Column names are cleaned into safe SQL identifiers, such as Order Date becoming order_date.
  3. Click Generate SQL, check the detected column types, then copy the SQL or download it and run it in your database client.

How column types are chosen

Each column gets the narrowest type that fits every non-empty value in it:

Values in the columnPostgreSQLMySQLSQLiteSQL Server
Whole numbersINTEGER or BIGINTINT or BIGINTINTEGERINT or BIGINT
DecimalsNUMERICDECIMAL(p,s)REALDECIMAL(p,s)
true/falseBOOLEANBOOLEANINTEGERBIT
Dates (2025-03-15)DATEDATETEXTDATE
Date and timeTIMESTAMPDATETIMETEXTDATETIME2
Anything elseTEXT or VARCHAR(n)VARCHAR(n) or TEXTTEXTNVARCHAR(n)

Numbers with leading zeros, like ZIP codes, are kept as text. Only ISO dates (YYYY-MM-DD) are treated as dates, because formats like 03/04/2025 are ambiguous. Always review the types before loading production data.

Faster ways to load big files

INSERT statements are fine for thousands of rows. For millions, use your database’s bulk loader, which is much faster:

-- PostgreSQL (psql)
\copy my_table FROM 'data.csv' WITH (FORMAT csv, HEADER true)

-- MySQL
LOAD DATA LOCAL INFILE 'data.csv' INTO TABLE my_table
FIELDS TERMINATED BY ',' ENCLOSED BY '"' IGNORE 1 LINES;

-- SQLite
.import --csv --skip 1 data.csv my_table

Or from Python with pandas: df.to_sql("my_table", engine, if_exists="replace", index=False). Once the data is in, our SQL for data analysis tutorial shows how to query it.

FAQ

Is my CSV uploaded?

No. The SQL is generated in your browser and nothing is sent to our server.

Are quotes in my data escaped safely?

Yes. Single quotes inside text are doubled (O'Brien becomes 'O''Brien'), which is the standard SQL escape in all four databases.

Can I add a primary key?

Add it after loading, for example ALTER TABLE my_table ADD PRIMARY KEY (order_id);. The converter doesn’t guess keys, because a column that looks unique in a sample may not be.

Related

Verified by MonsterInsights