CSV → SQL INSERT

Generate INSERT statements from CSV (header row + data).

Open tool

Overview

The CSV-to-SQL-INSERT generator takes a CSV with a header row and emits a series of INSERT statements ready to run against a database. You provide the target table name, pick a SQL dialect, and the tool produces one statement per row — or a single multi-row INSERT — quoted correctly for the target.

It's the bridge between a one-off export and a database load when you don't have a bulk import tool handy. Developers seeding a dev database, support engineers loading test fixtures, and analysts pushing a small dataset into a staging table reach for a csv to sql converter to skip writing a loader script.

How it works

CSV is parsed per RFC 4180. The header row becomes the column list; each data row becomes a VALUES tuple. The tool detects value types per cell — numbers, booleans, nulls, dates, and strings — and quotes accordingly. Strings are wrapped in single quotes with embedded quotes doubled (O'Brien'O''Brien').

Dialect controls a few syntactic differences: MySQL uses backticks for identifiers, PostgreSQL and SQL Server use double quotes (or square brackets for SQL Server), and SQLite is the most permissive. Boolean values become TRUE/FALSE for PostgreSQL and MySQL or 1/0 for SQL Server and SQLite.

Examples

Input:
id,name,active
1,Alice,true
2,O'Brien,false

Output (PostgreSQL):
INSERT INTO "users" ("id","name","active") VALUES (1, 'Alice', TRUE);
INSERT INTO "users" ("id","name","active") VALUES (2, 'O''Brien', FALSE);
Output (multi-row MySQL):
INSERT INTO `users` (`id`,`name`,`active`) VALUES
  (1, 'Alice', TRUE),
  (2, 'O\'Brien', FALSE);

FAQ

How are NULLs represented in the source CSV?

An empty cell becomes NULL by default. If you want literal empty strings instead, toggle the option — every system has different conventions, and the choice is yours.

Does it produce INSERT IGNORE or ON CONFLICT?

Optional. MySQL's INSERT IGNORE and PostgreSQL's ON CONFLICT DO NOTHING are available as flags so re-running a load doesn't error on existing primary keys.

What about date and timestamp columns?

Values that parse as ISO 8601 dates are wrapped in single quotes for the target dialect — that's portable across MySQL, PostgreSQL, SQL Server, and SQLite. Non-ISO formats stay as strings; convert in SQL if needed.

Try CSV → SQL INSERT

An unhandled error has occurred. Reload ×