CSV to SQL INSERT

Generate SQL INSERT statements from CSV, with an optional CREATE TABLE guessed from the data. Choose the table name, identifier quoting, multi-row output and NULL handling.

Use the tool

Why this tool exists

Loading a CSV into a database usually means an import wizard, a COPY command or a short script. For a small seed file, a test fixture or a quick migration, it is faster to have plain SQL you can read, review and commit.

Paste the CSV and the tool uses the first row as column names, then writes one INSERT per row or a single multi-row INSERT. Numbers are left bare, text is quoted with single quotes doubled, and empty cells can become NULL. The CREATE TABLE option guesses INTEGER, REAL or TEXT from the values, which is a starting point, not a final schema. Review column types before running anything on a real database. The conversion is local and nothing is uploaded.

How to use it

  1. Paste CSV with column names in the first row.
  2. Enter the table name and choose identifier quotes: double quotes, backticks or none.
  3. Tick Include CREATE TABLE, Single multi-row INSERT and Empty cells as NULL as needed.
  4. Copy the SQL and run it in your database client.

Frequently asked questions

How are column types guessed?

A column where every non-empty value is a whole number becomes INTEGER, one with decimals becomes REAL, and anything else TEXT. It is only a guess, so adjust types such as dates or decimals before using the table.

How are quotes in values handled?

Text values are wrapped in single quotes and any single quote inside is doubled, which is the standard SQL way. Identifiers are quoted with your chosen style.

Which SQL dialect does it target?

Plain INSERT and CREATE TABLE statements that work in most databases. Choose double quotes for PostgreSQL or SQLite, backticks for MySQL. Check dialect details such as types before running.

Is the output safe against SQL injection?

The tool escapes quotes, but you should still only run SQL generated from data you trust, and test it on a copy of the database first.