Tools / CSV ↔ SQL INSERT Converter

CSV ↔ SQL INSERT Converter.

Turn CSV rows into SQL INSERT statements for four dialects, or export INSERT statements as CSV.

Runs in your browser

Ctrl/⌘ + Enter to run · Ctrl/⌘ + Shift + C to copy the result

Result
Result
Stats

About CSV ↔ SQL INSERT Converter

The CSV ↔ SQL INSERT Converter is for the moment when a spreadsheet export has to land in a database table, or a table dump has to go back into a spreadsheet. It parses CSV the way RFC 4180 defines it: quoted fields, doubled quotes inside quotes, delimiters and line breaks inside quoted fields, and Windows or Unix line endings. The delimiter is detected from the first line, which helps with European exports that use semicolons, or you can force comma, semicolon, tab or pipe. The header row becomes the column list; without a header the columns are named column1, column2 and so on. Columns where every value is a plain number are written unquoted, while values with leading zeros, such as ZIP codes like 01234, stay quoted strings so the zeros survive. Empty cells become NULL unless you switch that off. For example the row A-100;"Desk; oak";249.90 becomes ('A-100', 'Desk; oak', 249.90). Quoting follows the chosen dialect, and an optional CREATE TABLE statement with inferred types is added in front. The reverse direction reads INSERT … VALUES statements, including multi-row inserts and dumps with comments, and writes CSV with a header row; a missing column list is filled from a CREATE TABLE in the same input. The most common import errors, an unterminated quote or a stray character after a closing quote, are reported with the exact line and column. Data never leaves the browser.

How to Use

  1. Paste CSV or INSERT statements and choose the direction.
  2. Set the table name, dialect and delimiter options.
  3. Copy or download the SQL or CSV.

Frequently Asked Questions

Why are some numbers quoted?

Only columns where every value is a plain number are left unquoted. Values with leading zeros, like 007 or ZIP codes, stay strings so the zeros are not lost.

Which delimiter is used?

With "auto" the delimiter that occurs most often in the first line (outside quotes) wins among comma, semicolon, tab and pipe. Choose one explicitly if the guess is wrong.

What if the SQL has several tables?

CSV holds one table, so the rows of the first table are exported and the other table names are listed in the stats.

Is the file uploaded?

No. Everything runs in your browser.

Related Tools