XlsConverter

CSV to SQL INSERT statements with inferred types

Upload the CSV file, set the delimiter, table name and SQL dialect, then convert. The .sql script creates the table and inserts every row, ready to run in your database.

CSV

Encrypted, auto-deleted

Demo converts up to 100 rows, once.
Database administrator with a laptop in a server room aisle

LOAD DATA and COPY are fast but strict about file paths, permissions and formats. A SQL script is portable: you can review it, send it to a colleague or run it on a managed database where file imports are restricted. XlsConverter writes that script from any CSV.

MySQL is the default dialect, with PostgreSQL and SQLite as options. For spreadsheet sources, see XLSX to SQL or Excel to PostgreSQL.

How to convert CSV to SQL in three steps

  1. 1Upload the .csv file.
  2. 2Confirm delimiter and header, then set table name and dialect.
  3. 3Convert and download the .sql script.

CSV has no types, so the script has to decide

Every CSV value is text. The converter samples the whole column, not just the first rows, before choosing INTEGER, DECIMAL, DATE or VARCHAR. A column that is numeric for 10,000 rows and holds "TBD" on row 10,001 becomes VARCHAR, which prevents the script from failing halfway.

Escaping is where hand written scripts break. Apostrophes in names like O'Brien, backslashes in file paths and multibyte characters all need dialect specific escaping. The converter escapes each value for the chosen dialect and writes the file as UTF-8, with SET NAMES utf8mb4 for MySQL.

Batching keeps large files fast. Multi row INSERT statements of a few hundred rows each load quickly without exceeding the server packet size. If your source is JSON rather than CSV, convert it first with JSON to CSV, and for MySQL specific details see Excel to MySQL.

CSV to SQL questions

How do I convert a CSV file into SQL INSERT statements?

Upload the CSV, set the table name and dialect, and convert. The script contains a CREATE TABLE and batched INSERT statements.

Which databases does the CSV to SQL script work with?

MySQL, PostgreSQL and SQLite, with quoting and types matched to the dialect you choose.

How are apostrophes in values handled?

They are escaped correctly for the selected dialect so the script runs without syntax errors.

Why use a SQL script instead of LOAD DATA or COPY?

A script works where file imports are disabled, such as many managed databases, and it can be reviewed before running.

Can I check the CSV to SQL output before paying?

There is a one-time demo for up to 100 rows. Full files need a paid plan, from 24 USD per month billed yearly.

Related converters

Convert full files and batches

Pro starts at $24 per month billed yearly. Cancel any time.

See plans