Free, browser-based utilities for everyday developer workflows

Convert CSV to SQL INSERT statements

Paste CSV and get INSERT statements with the header as the column list and values quoted correctly — plus an upsert option so re-running does not create duplicates.

Open this example in CSV to SQL Insert/Upsert

Open the tool, then paste the sample input below. Everything runs locally in your browser.

Open this example in CSV to SQL Insert/Upsert →

The problem

You have data in a CSV and need to load it into a table. Writing INSERT statements by hand means matching columns, quoting strings, and escaping quotes — easy to get wrong over many rows. Generating them from the CSV header keeps the column order and quoting consistent.

Sample input

CSV
id,name,email
1,Ada,ada@example.com
2,Ben,ben@example.com

Expected output

SQL
INSERT INTO users (id, name, email) VALUES
  (1, 'Ada', 'ada@example.com'),
  (2, 'Ben', 'ben@example.com');

The header becomes the column list, numbers stay unquoted, and string values are single-quoted. An upsert variant adds ON CONFLICT / ON DUPLICATE KEY so re-runs update instead of duplicate.

How to do it

  1. Paste the CSV including its header row.
  2. Set the target table name.
  3. Choose INSERT or upsert.
  4. Generate the statements.
  5. Copy the SQL into your migration or console.

Common mistakes

  • A missing header row, so the column list is wrong.
  • Unescaped single quotes inside string values.
  • Quoting numeric or boolean columns that should stay bare.
  • Inserting without an upsert and creating duplicate rows on re-run.
  • A delimiter mismatch (semicolons or tabs) splitting columns wrong.

Related tools

Related guides

FAQ

How do I convert CSV to SQL INSERT statements?

Paste the CSV with its header, set the table name, and generate. The header becomes the column list and each row becomes a VALUES tuple with correct quoting.

Can I generate an upsert instead of a plain insert?

Yes. Choose the upsert option to add ON CONFLICT or ON DUPLICATE KEY UPDATE so re-running the statements updates existing rows instead of duplicating them.

How are quotes and special characters handled?

String values are single-quoted and embedded single quotes are escaped, so values containing apostrophes do not break the statement.

What if numbers get quoted?

Mark numeric and boolean columns so they are emitted unquoted; quoting them can cause type conversions or defeat constraints.

Is my CSV uploaded?

No. The SQL is generated locally in your browser. Your data is not sent to a server.

INSERT statements are generated locally in your browser. Your CSV is not uploaded.

Explore more data cleanup and QA tools

Convert CSV to SQL, build filters and joins, inspect data and format queries — grouped in one place.

View the data cleanup & QA toolkit →