CSV to SQL INSERT converter
Paste CSV data and get INSERT statements for MySQL, PostgreSQL or SQLite. The header row gives the column names, text is quoted and escaped, plain numbers are left bare, and rows can be grouped into multi-row statements.
Runs in your browser: nothing you enter is sent anywhere.
How to use it
- Paste CSV. The first row holds the column names unless you turn that option off, in which case columns are called col1, col2 and so on.
- Type the table name and choose the dialect and the delimiter.
- Set the rows per statement and the NULL and number options, then copy the SQL.
Example
id,name
1,"O'Brien"
2,
With PostgreSQL, a batch of 100 and empty cells as NULL:
INSERT INTO "users" ("id", "name") VALUES
(1, 'O''Brien'),
(2, NULL);
Tips
Quoted fields may contain the delimiter, quotes (written twice) and line breaks. If a row has more values than the header, the tool reports the row number instead of guessing. Large files are better loaded with your database’s own import command, such as COPY in PostgreSQL or LOAD DATA in MySQL.
Frequently asked questions
How are names and text quoted for each dialect?
MySQL uses backticks around table and column names, PostgreSQL and SQLite use double quotes. Text values are single-quoted with a quote doubled ('' for '). For MySQL, backslashes are doubled too, because MySQL reads them as escapes by default. A table name such as public.users is split at the dot and each part is quoted.
Which values stay unquoted?
With the numbers option on, only plain decimal numbers such as 5, -3 or 9.5. Values with leading zeros (007), exponents (1e5), hex or more than 15 digits stay as quoted text, so zip codes and ids keep their form. Turn the option off to quote everything.
What do the NULL and batch options do?
With NULL on, an empty cell is written as NULL instead of an empty string, and a row with fewer values than the header is padded with NULL. The batch size sets how many rows go into one INSERT; 1 gives one statement per row.
Are dates and booleans recognised?
No. They are written as quoted text, which most databases convert on insert. Edit the output if your column types need something else.
Is the SQL safe to run on any database?
The escaping covers quotes in values, but this is a convenience for loading data you trust. For input from users, use parameterised queries in your code instead of building SQL strings.