CSV to SQL

Generate SQL statements (INSERTs) from your CSV data.

About CSV to SQL

Loading a spreadsheet into a database usually means writing INSERT statements by hand or fighting an import wizard. This tool turns each CSV row into an INSERT INTO statement, or into an UPDATE statement keyed on the first column, using backtick-quoted identifiers that MySQL and MariaDB accept and that most other engines tolerate after a quick replace.

Paste the CSV, type the table name, pick INSERT or UPDATE and copy the generated statements into your SQL client. Generation runs in your browser, so a customer list is never uploaded anywhere.

How to use CSV to SQL step by step

  1. Paste the CSV in the left box. The header row supplies the column names.
  2. Enter the target table name (my_table by default).
  3. Choose the statement type: INSERT to add rows, or UPDATE to modify rows matching the first column.
  4. Click "Generate SQL" and then "Copy" to place the statements on the clipboard.

Input and output example

Input

id,name,city
1,Ana,Madrid
2,Luis,Sevilla
(table: users, type: INSERT)

Output

INSERT INTO `users` (`id`, `name`, `city`) VALUES ('1', 'Ana', 'Madrid');
INSERT INTO `users` (`id`, `name`, `city`) VALUES ('2', 'Luis', 'Sevilla');

Why use our CSV to SQL?

Common use cases

Limits and tips

Frequently asked questions

What is the difference between the INSERT and UPDATE options?

INSERT generates one INSERT INTO statement per row and adds new records to the table. UPDATE generates one UPDATE statement per row that sets every column except the first, using the first column as the key in the WHERE clause, so existing records are modified instead of created.

Does it work with PostgreSQL or SQL Server?

The statements use backticks around table and column names, which is MySQL and MariaDB syntax. For PostgreSQL replace backticks with double quotes, and for SQL Server with square brackets; the rest of the syntax is standard SQL.

Why are numbers written in quotes?

CSV has no types, so the generator treats every cell as a string and quotes it. MySQL, SQLite and MariaDB implicitly convert '1' to 1 in a numeric column. If your engine rejects that, remove the quotes for numeric columns with a search and replace.

How do I handle NULL values?

Empty cells are inserted as empty strings (''), not as NULL. After generating the statements, replace '' with NULL where needed, or set a default in the table definition.

Is the CSV sent to a server?

No. The SQL text is built in your browser and shown in the result box; nothing is uploaded or stored.

Related guides

Related tools

Other free utilities you may find useful

Available languages