Paste or upload a CSV, set the table name and SQL dialect, and copy or download the INSERT statements. Supports batching, NULL handling, and CREATE TABLE.
This tool runs entirely in your browser. What you enter is never sent anywhere.Your input is never sent anywhere.
DetailsCSV Data
| id# | nameAa | age# | emailAa |
|---|---|---|---|
| 1 | Emily Carter | 28 | [email protected] |
| 2 | Michael O'Brien | 34 | [email protected] |
| 3 | Johnson, Sarah | (empty) | [email protected] |
SQL Settings
Table name
SQL dialect
Rows per INSERT (batch size, 1–1000)
Data rows
3
SQL statements
1
Generated SQL
INSERT INTO `my_table` (`id`, `name`, `age`, `email`) VALUES (1, 'Emily Carter', 28, '[email protected]'), (2, 'Michael O''Brien', 34, '[email protected]'), (3, 'Johnson, Sarah', NULL, '[email protected]');
Estimated column types (used for CREATE TABLE)
Convert CSV to SQL INSERT Statements in Your Browser
Typing INSERT statements by hand from a spreadsheet is slow, and it is easy to miss an escaped quote or a column. This tool reads a CSV and writes the SQL for you.
Paste the data or upload a file, pick MySQL, PostgreSQL, SQLite, or SQL Server, and the INSERT statements appear as you change settings. You can keep numeric columns unquoted, turn empty cells into NULL, split large files into batches, and add a CREATE TABLE statement based on the data.
The CSV is parsed and converted in your browser, so you can use it with files that contain customer or internal data.
Seed Data, Migrations, and Quick Imports
Seeding a dev or staging database
Turn a spreadsheet of test users, products, or orders into SQL you can run against a development or staging database.
Moving data between systems
Export a table from a CRM, billing tool, or other SaaS app as CSV, then generate the INSERT statements for your own database.
Loading a spreadsheet from a coworker
Sales, ops, or finance sends an Excel or Google Sheets export. Save it as CSV and generate the SQL instead of writing it row by row.
Practicing SQL with sample data
Load a small CSV into a local database to try joins, filters, and aggregates on data you understand.
From Pasted CSV to Copy-Ready SQL in 4 Steps
- Paste your CSV into the text box, or choose a .csv file.
- Check the delimiter (comma, tab, or semicolon) and whether the first row is a header.
- Enter the table name and choose your SQL dialect.
- Adjust the batch size and options such as NULL conversion or CREATE TABLE, then copy the SQL or download it as a .sql file.
Note: The preview shows the first five rows and marks each column as numeric (#) or text (Aa), so you can spot a wrong delimiter before you copy anything.
Check These Before You Run the SQL
- The SQL reflects your CSV as it is. Read it first and test it on a copy of the database.
- A column is treated as numeric only if every non-empty value is a plain number, such as 42, -7, or 3.14, with no leading zero. Values with thousands separators, currency symbols, or exponents (1,200, $5, 1e5) are quoted as text.
- Dates and times are inserted as quoted text exactly as they appear in the CSV. Reformat them first if your database expects a different format.
- CREATE TABLE uses estimated types: INT, BIGINT (more than 9 digits), DECIMAL(18,4), or VARCHAR in steps of 50. It adds no keys or constraints and uses the same type names for every dialect, so treat it as a starting point.
- A row with fewer cells than the header gets empty values for the missing columns. A row with more cells has the extra values dropped.
- Quote characters (backticks, double quotes, and square brackets) are removed from table and column names before the names are quoted.
Identifier Quoting by Database
Each database quotes table and column names differently. Switching the dialect in the tool changes the output to match this table.
| Dialect | Name quoting | Text values | Notes |
|---|---|---|---|
| MySQL | `backticks` | 'single quotes' | Backslashes in text values are doubled in the output |
| PostgreSQL | "double quotes" | 'single quotes' | Quoted names are case-sensitive |
| SQLite | "double quotes" | 'single quotes' | Same quoting style as PostgreSQL |
| SQL Server | [square brackets] | 'single quotes' | Useful for column names that match reserved words |
INSERT Syntax, Escaping, and Batch Size
A short look at the SQL this tool writes and why it makes the choices it does.
Basic INSERT syntax and column lists
The general form is INSERT INTO table (column, ...) VALUES (value, ...);
Listing the columns means the values still line up if the table's column order changes later, and it lets you load only some columns. Turn off "Include column names" if your CSV matches the table's column order exactly.
Escaping single quotes
A value like O'Brien breaks a SQL string unless the quote is escaped. The tool writes it as O''Brien. In MySQL output it also doubles backslashes, because MySQL treats a backslash in a string as an escape character by default.
If you run SQL from application code with user input, use parameterized queries instead of building strings. This tool is meant for loading data you control.
Batch size and multi-row INSERT
Putting several rows in one VALUES list usually means fewer round trips than one statement per row. Very long statements can run into limits on query or packet size, so the tool splits the data by the batch size you set. Use a smaller batch if your server rejects a statement, or 1 for one row per statement.
NULL vs. an empty string
In SQL, NULL means no value, while '' is a real, empty piece of text. They behave differently in filters like IS NULL and in counts. A CSV cannot tell the two apart, so you choose: empty cells become NULL when the option is on, and '' when it is off.
PostgreSQL treats a quoted name as case-sensitive, so a column created as "Email" must be quoted that way in later queries.
Common Import Errors and How to Fix Them
Columns shift because a value contains a comma
A value like "Austin, TX" is split at the comma when a script cuts each line on commas. Every value after it moves one column to the right.
💡 See the solution▼
Syntax error from a name with an apostrophe
A value like O'Brien ends the SQL string early and the statement fails with a syntax error near the apostrophe.
💡 See the solution▼
ZIP codes lose their leading zero
A ZIP code like 02134 inserted as a number becomes 2134, and a phone or ID number with leading zeros changes the same way.
💡 See the solution▼
Empty cells stored as '' instead of NULL
Empty strings do not match IS NULL, so filters and counts that expect NULL return the wrong rows.
💡 See the solution▼
Quoting error from the wrong dialect
SQL generated with backticks for MySQL fails in PostgreSQL or SQL Server with an error about the identifier.
💡 See the solution▼
One huge INSERT is rejected by the server
Tens of thousands of rows in a single statement can exceed the server's maximum query or packet size.
💡 See the solution▼
CSV Import FAQ
Q.What if my CSV has no header row?
A. Uncheck "First row is a header." The tool then names the columns col1, col2, col3, and so on, and treats every row as data. You can rename the columns in the generated SQL afterward.
Q.Is it safe to run the generated SQL on a production database?
A. The tool doubles single quotes in text values (and backslashes in MySQL output), but the SQL still reflects whatever is in your CSV. Read the output first and run it on a copy or staging database before you run it on production.
Q.Which databases does it support?
A. MySQL (backticks), PostgreSQL (double quotes), SQLite (double quotes), and SQL Server (square brackets). Switching the dialect changes how table and column names are quoted. The INSERT statements use multi-row VALUES lists.
Q.Does it handle commas, quotes, and line breaks inside a field?
A. Yes, as long as the field is wrapped in double quotes, which is how Excel and Google Sheets export them. A field like "Johnson, Sarah" stays in one column, and a doubled quote ("") inside a quoted field becomes a single quote character.
Q.How do I convert a large CSV with thousands of rows?
A. Set "Rows per INSERT" to split the data into several statements. The batch size can be anywhere from 1 to 1000, and the default is 100. Smaller batches produce shorter statements that are less likely to hit your server's query size limit.
Q.How are empty cells handled?
A. With "Convert empty cells to NULL" on, empty and whitespace-only cells become NULL. With it off, they are inserted as empty strings (''). Turn it on for numeric or date columns, where an empty string can cause a type error.
Q.Why are my ZIP codes or IDs with leading zeros quoted?
A. A column is left unquoted only if every non-empty value is a plain number without a leading zero. Values like 02134 or 007 keep their quotes so the leading zeros are not lost. Mixed columns, such as numbers and text, are also quoted.
Q.Can I use a CSV saved from Excel?
A. Yes. The file is read as UTF-8, so choose "CSV UTF-8" when you save from Excel. The tool removes the byte order mark at the start of the file. A file saved in another encoding may show garbled characters.
Q.Can I include a schema name in the table name?
A. Yes. Enter a name such as public.users and each part is quoted separately, for example "public"."users" in PostgreSQL or [dbo].[users] in SQL Server.
Q.Is my CSV uploaded to a server?
A. No. The file is read and converted in your browser, and the tool does not send the CSV or the generated SQL anywhere.
Your feedback
makes this tool better.
Tell us which features you'd like, what should be fixed, or which new tool you'd like to see. An engineer reads every submission and uses it to guide development.