Guide

Converter

CSV to SQL Converter

Turn the rows of a CSV into SQL INSERT statements for MySQL, PostgreSQL, SQLite or SQL Server. It runs in your browser.

Loading the tool…

.csv · .tsv · .txt

How to use it

  1. Add your CSVOpen a .csv, .tsv or text file. The separator is detected, and you can change it.
  2. Choose your databasePick MySQL, PostgreSQL, SQLite or SQL Server, then set the table name and the options.
  3. Copy or downloadCopy the SQL, or save it as a .sql file.
The CSV to SQL tool with a small CSV loaded: the counts of rows, columns and statements, the generated MySQL INSERT statement, and the dialect and quoting options.
The tool with sample data loaded. The names and numbers are made up.

Good to know

Text is escaped for the database you pick: quotes everywhere, backslashes in MySQL, and N'...' for text with accents or other non-ASCII letters in SQL Server. A column is written as numbers only when every value in it is a plain number, so zip codes like 01234 and long ids stay text, and one stray value such as N/A makes the whole column text. Empty cells become NULL. This tool writes INSERT statements only, so create the table first, and try the script on a copy of your database before you run it on the real one.

Worked example: one CSV, two databases

This is the CSV we used in our tests. It has the awkward things real files have: a zip code with a leading zero, a 20-digit id, a price with a trailing zero, a quote mark, a backslash and an empty cell.

people.csv

id,name,zip,note,amount
1,Ana O'Neil,01234,C:\temp\new,12.50
2,Zoë Müller,90210,,3
12345678901234567890,Sam Lee,007,"say ""hi""",-4.5

MySQL output (table name: people)

INSERT INTO `people` (`id`, `name`, `zip`, `note`, `amount`) VALUES
  ('1', 'Ana O''Neil', '01234', 'C:\\temp\\new', 12.50),
  ('2', 'Zoë Müller', '90210', NULL, 3),
  ('12345678901234567890', 'Sam Lee', '007', 'say "hi"', -4.5);

SQL Server output

INSERT INTO [people] ([id], [name], [zip], [note], [amount]) VALUES
  ('1', 'Ana O''Neil', '01234', 'C:\temp\new', 12.50),
  ('2', N'Zoë Müller', '90210', NULL, 3),
  ('12345678901234567890', 'Sam Lee', '007', 'say "hi"', -4.5);

What to notice:

What changes between the four databases

MySQLPostgreSQL / SQLiteSQL Server
Names are quoted withbackticks: `people`double quotes: "people"square brackets: [people]
Backslash in textdoubledleft as it isleft as it is
Text with accentsplain quotesplain quotesN'…' prefix
Rows per INSERT500 by default500 by default500 by default, 1,000 at most

Standard SQL / other writes double-quoted names and no special prefixes. The statements create no table, so create the table first with column types that suit your data, and try the script on a copy of your database. Going the other way, the SQL to CSV tool turns INSERT statements back into a CSV. If your data starts in Excel, use XLSX to CSV first.

How we tested this

On 31 October 2026 we ran the live page in headless Chromium on a Linux cloud server, driving it the way a person would (adding files, clicking the buttons, saving the download) and checking the files it produced.

What we checkedResult
The example above in all five dialect settings: names quoted the right way, 01234, 007 and the 20-digit id kept as text, 12.50 kept, empty cell as NULL, apostrophe doubled, MySQL backslash doubled, SQL Server N prefix37 of 37
Download file is identical to the text box, quoting can be turned off, 2 rows per INSERT gives 2 INSERTs, no page errors, no requests to other sites5 of 5
120 random CSV files (quotes, commas, semicolons, backslashes, new lines, emoji, Japanese, empty cells, NULL as text) converted in SQLite and PostgreSQL style, loaded into a real SQLite database, and compared cell by cell with the CSV120 of 120
Total162 of 162

Not tested: MySQL, PostgreSQL and SQL Server themselves. The MySQL and SQL Server text follows each database's documented escaping rules, and the PostgreSQL-style output was loaded into SQLite, which reads the same syntax, not into PostgreSQL.

Frequently asked questions

Which databases are supported?

MySQL, PostgreSQL, SQLite and SQL Server. Each one gets its own name quoting, true/false style and text escaping. For any other database, choose Standard SQL / other.

Is my data uploaded?

No. The SQL is generated in your browser. Your file and the SQL are not saved; only your option choices are remembered.

How does it decide what is a number?

A column is written as numbers only when every value in it is a plain number such as 12, -3 or 4.50. Values with a leading zero (01234, 007), a plus sign, an exponent, thousands commas or more than 15 digits before the point stay text, and so does a column with even one other value. You can also turn number detection off so that everything is written as text in quotes.

Does it create the table?

No. It writes INSERT statements only. Create the table first, with column types that suit your data.

What happens to column names with spaces or capitals?

By default every table and column name is quoted, so spaces and capitals are kept exactly. In PostgreSQL that means later queries must quote them the same way. Turn quoting off for plain names; a name that needs quotes still gets them. Blank or repeated column names are renamed (a_2, column_3), because a table cannot have two columns with the same name.

Can I convert a big file?

Yes. Open it as a file. Each INSERT holds 500 rows by default (SQL Server allows at most 1,000). Very large scripts show only the start in the box, while Copy and Download give everything.

My data is in an Excel file. What do I do?

Save the sheet as a CSV file first, or use the XLSX to CSV tool on this site, then open the CSV here.

Where to go next

When people use it