CSV to SQL INSERT Generator

Convert CSV to SQL INSERT statements for MySQL, PostgreSQL, SQLite or SQL Server, with CREATE TABLE (types guessed), batching, NULLs, transactions and safe escaping.

Tool

Was this tool useful?

About this tool

About CSV to SQL INSERT Generator

Import spreadsheet data into a database without a GUI. Paste or upload a CSV, choose your database and table name, and get INSERT statements with properly quoted names and escaped values (O’Neil stays safe). The generator can add a CREATE TABLE with column types guessed from the data (INT, DECIMAL, DATE, DATETIME, BOOLEAN, VARCHAR), group rows into multi-row INSERTs, turn empty cells into NULL, wrap everything in a transaction and skip rows that already exist.

How it works

Strings are wrapped in single quotes with ' doubled (and backslashes escaped for MySQL); numbers and booleans are written without quotes.

Example

id,name / 1,O'Neil → INSERT INTO `products` (`id`, `name`) VALUES (1, 'O''Neil');

How to use this tool

  1. Paste or choose the CSV.
  2. Choose the database, table name and options.
  3. Copy or download the .sql file and run it.

Frequently asked questions

How many rows per INSERT?

100–1000 is fast and safe for most servers. SQL Server allows at most 1000 rows per VALUES list.

Are the guessed types always right?

They are a good start. Check lengths and change VARCHAR sizes or add keys before running on production.

Is my data uploaded?

No. Everything is processed in your browser and stays on your device.

Are my files uploaded by the CSV to SQL INSERT Generator?

No. The CSV to SQL INSERT Generator reads your files in your browser, so your data stays on your device. Very large files may be slow on older phones.