Convert CSV to SQL INSERT and UPDATE queries
This CSV to SQL converter turns a spreadsheet export into ready-to-run SQL: a CREATE TABLE statement with a sensible type for every column, followed by batched INSERT statements — or one UPDATE … WHERE per row when you need to change rows that already exist. Pick MySQL/MariaDB, PostgreSQL, SQLite or SQL Server and the identifiers, string literals, booleans and types change to match that database.
It is meant for the jobs that come up every week: loading a client’s spreadsheet into a staging table, seeding a development database, turning a price list into an update script, or moving a JSON API response into SQL. JSON input works too — switch to JSON and paste an array of objects.
Everything runs in your browser, so customer lists and other private data never leave your device.
How to use the CSV to SQL Converter
- Paste CSV into CSV data, drop a
.csvfile on it or press Load file. For JSON, choose JSON first (a.jsonfile switches automatically). - Choose the Database and type the Table name. Use
schema.tableto include a schema. - Pick INSERT (+ CREATE TABLE) or UPDATE … WHERE key, and the Primary / key column. Auto picks a column named
idwhen its values are unique. - Check Column types. Each column is typed from all of its values; use Override if, say, a numeric code should stay text.
- Set the options you need — rows per INSERT, quoting, DROP TABLE IF EXISTS, a transaction, NULL handling — then Copy SQL or Download .sql.
CSV to SQL Converter features
Real CSV parsing
Follows RFC 4180: quoted fields, doubled quotes (""), commas and line breaks inside quotes, CRLF or LF endings and a byte-order mark. Comma, semicolon, tab and pipe are detected automatically.
Types inferred from every value
Integers (INT or BIGINT by range), decimals with exact precision and scale, booleans, ISO dates and timestamps, and text sized to the longest value. Numbers with leading zeros, such as PIN codes and phone numbers, stay text.
Correct escaping per database
Single quotes are doubled everywhere; MySQL also gets backslashes escaped; SQL Server text uses N'…' literals. Reserved or unusual names are quoted with backticks, double quotes or brackets.
Batched INSERTs
One INSERT per row or multi-row INSERTs of 10 to 5,000 rows. SQL Server is capped at its limit of 1,000 rows per VALUES list.
UPDATE queries from CSV
Generate UPDATE table SET … WHERE key = …; for every row, keyed on any column — handy for bulk price or status changes.
JSON to SQL
An array of objects becomes rows; keys become columns; nested objects and arrays are stored as JSON text.
How column types are chosen
Every non-empty value in a column is checked, not just the first few rows, so one stray word turns a column into text instead of breaking your import later. Empty cells (and the words NULL or \N, if that option is on) count as NULL and do not affect the type.
| Values in the column | MySQL | PostgreSQL | SQLite | SQL Server |
|---|---|---|---|---|
| true / false | BOOLEAN | BOOLEAN | INTEGER (1/0) | BIT (1/0) |
| Whole numbers up to 2,147,483,647 | INT | INTEGER | INTEGER | INT |
| Larger whole numbers | BIGINT | BIGINT | INTEGER | BIGINT |
| Decimals such as 1499.50 | DECIMAL(p,s) | NUMERIC(p,s) | REAL | DECIMAL(p,s) |
| 2026-10-24 | DATE | DATE | TEXT | DATE |
| 2026-10-24 09:30:00 | DATETIME | TIMESTAMP | TEXT | DATETIME2 |
| Anything else | VARCHAR(n) or TEXT | TEXT | TEXT | NVARCHAR(n) or (MAX) |
Escaping and quoting rules used
- Strings: a single quote becomes two (
O'Neil→'O''Neil'), the standard SQL rule all four databases accept. Line breaks inside a value are kept inside the literal. - MySQL backslashes: MySQL treats
\as an escape character unless theNO_BACKSLASH_ESCAPESSQL mode is on, soC:\tempis written as'C:\\temp'. PostgreSQL (with the defaultstandard_conforming_strings), SQLite and SQL Server keep backslashes as typed. - Names: left bare when they are plain letters, digits and underscores; otherwise — or when the name is a reserved word such as
orderorwhen— quoted as`name`,"name"or[name]. PostgreSQL names with capitals are quoted so their case survives. - Dates are written as ISO 8601 strings, which every database casts to its date and timestamp types.
Loading the result
Run the file with your usual client — mysql db < customers.sql, psql -f customers.sql, sqlite3 shop.db < customers.sql or SQL Server Management Studio. For very large files a native bulk loader (LOAD DATA, COPY, .import, BULK INSERT) is faster; this tool is ideal up to a few hundred thousand rows. To try the statements first, open the online SQL compiler, a SQLite playground in your browser. Tidy the output with the SQL formatter, or turn the same CSV into JSON with CSV to JSON.
CSV to SQL Converter FAQ
How do I convert a CSV file to SQL INSERT queries?
Load the CSV, choose your database and table name, keep “INSERT (+ CREATE TABLE)” selected and press Download .sql. The file contains the CREATE TABLE statement followed by INSERT statements for every row.
Can I create an UPDATE query from a CSV?
Yes. Choose “UPDATE … WHERE key” and pick the key column. Each row becomes UPDATE table SET col = value, … WHERE key = value;. Rows with an empty key are skipped and reported.
Which databases does the CSV to SQL converter support?
MySQL and MariaDB, PostgreSQL, SQLite and Microsoft SQL Server. The types, quoting, boolean literals, transaction keywords and batch limits follow each one.
Why is a numeric-looking column typed as text?
Values with leading zeros (00123), plus signs, thousands separators or any non-numeric entry make the column text so nothing is lost. Use Override to force a numeric type; values that are not valid numbers are then still written as quoted strings.
How are empty cells handled?
With “Empty cells → NULL” on, empty fields become NULL; turn it off to insert empty strings. The words NULL and \N (the MySQL dump marker) can also be read as NULL.
Is my data uploaded anywhere?
No. Parsing and SQL generation happen in your browser tab and nothing is sent to a server.