CSV to SQL INSERT Generator

Turn a CSV file into SQL INSERT statements.

Free CSV to SQL INSERT generator that parses RFC 4180 CSV and builds ready-to-run INSERT statements for PostgreSQL, MySQL or SQL Server, with optional number and boolean inference. Runs entirely in your browser, so nothing is uploaded. It runs free in your browser on Gera Tools, with nothing uploaded.

Last updated Source: Gera Tools

How are values typed in the output?

With inference on, clean numbers stay unquoted, true/false become TRUE/FALSE, empty cells and null become NULL, and everything else is quoted as a string. Turn it off to quote every value.

This tool converts CSV data into SQL INSERT statements — one statement per data row — ready to run in psql, the MySQL client, SQLite or SQL Server. It is a fast way to load a spreadsheet or export into a database table without writing the INSERTs by hand or setting up an import tool.

How it works

The first row of the CSV is treated as the column names, and you supply the table name. Each following row becomes an INSERT INTO table (cols) VALUES (...) statement. An RFC 4180-aware parser handles quoted fields, embedded commas and doubled quotes. With type inference on, the tool emits appropriate SQL literals:

Cell valueSQL output
clean number (e.g. 42)42 (unquoted)
true / falseTRUE / FALSE
empty cell or “null”NULL
anything else'quoted string' (single quotes doubled)

Turn inference off to quote every value as a string.

Example

Given the CSV:

id,name,active
1,Ada,true
2,"Bao, Jr.",false

with table name users, it produces:

INSERT INTO users (id, name, active) VALUES (1, 'Ada', TRUE);
INSERT INTO users (id, name, active) VALUES (2, 'Bao, Jr.', FALSE);

Note the number stays unquoted, the booleans become TRUE/FALSE, and the comma inside “Bao, Jr.” is kept as part of the string.

Dialect differences

Different databases have slightly different INSERT syntax. This tool handles the three main dialects:

DialectQuoting styleBoolean syntaxNULL
PostgreSQLDouble quotes for identifiers, single quotes for stringsTRUE / FALSENULL
MySQLBacktick quotes for identifiers (optional), single quotes for stringsTRUE / FALSE or 1 / 0NULL
SQL ServerSquare brackets for identifiers, single quotes for strings1 / 0 (no TRUE/FALSE keyword in older versions)NULL

Pick the dialect that matches your target database before copying.

Security note: SQL injection

The tool doubles any single quote inside a string value (' becomes ''), which is the standard SQL escaping rule and prevents the most basic injection from literal data. However, the generated statements are designed for loading trusted data from a spreadsheet, not for dynamically building queries from untrusted user input. When building application queries from user-supplied data, always use parameterized queries / prepared statements in your database driver rather than string concatenation.

Practical workflow

  1. Export a table or report to CSV from your source (Excel, Google Sheets, database, API).
  2. Paste it here, enter the target table name, and pick the dialect.
  3. Toggle type inference on (or off for all-text imports).
  4. Copy the generated statements and run them in your database client, or save as a .sql migration file.

This is faster than writing INSERTs by hand for a one-time load, and more transparent than a GUI import wizard when you need to review exactly what SQL will run. Everything runs locally in your browser — nothing is uploaded.