Skip to main content

CSV to SQL

Turn CSV into SQL INSERT statements in your browser. MySQL, PostgreSQL, SQL Server and SQLite quoting, with an optional CREATE TABLE.

All Data tools →

This tool runs entirely in your browser. Nothing you enter is sent to our servers, so there is nothing for us to store or see.

About the CSV to SQL

Paste CSV and get SQL INSERT statements back as you type, with an optional CREATE TABLE to go with them. Everything runs inside this page on your own device, so nothing you paste is uploaded.

The four dialects differ in ways that produce a script which fails on the first line, so the dialect is a real setting rather than a label. Identifiers are quoted with backticks on MySQL, double quotes on PostgreSQL and SQLite, and square brackets on SQL Server — and the quote character itself is doubled when it appears inside a name, which is the part generators forget. String values escape a single quote by doubling it everywhere; MySQL additionally treats a backslash as an escape character by default, so backslashes are doubled there and left alone elsewhere. Getting that wrong silently corrupts any value containing a Windows path.

Empty cells become NULL rather than an empty string, because that is what a blank cell in a spreadsheet almost always means. Numeric detection is optional and, when enabled, only unquotes values that survive a round trip unchanged — so a product code like 00714 stays a quoted string instead of being inserted as the number 714.

Multi-row inserts are batched at a thousand rows per statement. That is SQL Server's hard limit on a single VALUES clause, and it is a sensible batch size on the others too — one statement holding fifty thousand rows tends to exceed the server's maximum packet size and fails with an error that says nothing about why.

How to use the CSV to SQL

  1. Paste your CSV

    Paste into the left pane, or drop a .csv file onto it — dropping reads the file locally and never uploads it.

  2. Pick your database

    MySQL, PostgreSQL, SQL Server or SQLite. This sets how identifiers are quoted and how strings are escaped, both of which differ enough to break a script.

  3. Name the table and choose extras

    Set the table name, and add a CREATE TABLE if you are loading into a fresh database. Turn on numeric detection if your numbers should be inserted unquoted.

  4. Copy or download

    The script appears on the right as you type. Copy it into your client, or download it as a .sql file.

Frequently asked questions

Is my data uploaded anywhere?

No. The conversion runs inside your browser and nothing is sent to a server. You can disconnect from the internet once the page has loaded and it will keep working exactly as before.

Why does the dialect matter?

Because identifier quoting and string escaping genuinely differ, and getting either wrong produces a script that fails on its first statement. MySQL uses backticks, PostgreSQL and SQLite use double quotes, SQL Server uses square brackets — and MySQL treats a backslash inside a string as an escape character, which the others do not.

How are quotes and backslashes in my data handled?

A single quote is doubled, which is the standard escape in every dialect. On MySQL a backslash is also doubled, because it is an escape character there by default — without that, any value containing a Windows path is silently corrupted on insert. On the other dialects backslashes are left exactly as they are.

Why are my empty cells becoming NULL?

Because a blank cell in a spreadsheet almost always means "no value" rather than "the empty string", and NULL is the honest representation of that. If you need empty strings instead, a single find-and-replace on the generated script will convert them.

What types does the CREATE TABLE use?

Every column is created as text — TEXT on MySQL, PostgreSQL and SQLite, and NVARCHAR(MAX) on SQL Server. Inferring types from a sample is guesswork that goes wrong on exactly the columns that matter, such as an ID with leading zeros, so it is left to you to adjust the definition deliberately.

Why is my output split into several INSERT statements?

They are batched at a thousand rows each. That is SQL Server's hard limit for one VALUES clause, and a good size elsewhere too — a single statement carrying fifty thousand rows usually exceeds the server's maximum packet size and fails with an error that gives no hint of the real cause.