CSV to SQL Converter: Free INSERT Statement Generator
Turn a CSV file into ready-to-run SQL INSERT statements for MySQL, PostgreSQL, or SQLite. Optional CREATE TABLE with inferred column types, batched inserts, all in your browser.
What this tool does
This tool reads a CSV file, either pasted directly or uploaded, and generates SQL INSERT statements you can run against MySQL, PostgreSQL, or SQLite. The parser understands quoted fields, so commas and quotes inside a cell do not break the output. You choose a table name, a dialect, and how many rows go into each INSERT batch. With type inference turned on, the tool looks at every value in a column and decides whether it should be a number, a decimal, or text, so numeric columns are written unquoted and text columns are quoted and escaped correctly. Turn on CREATE TABLE generation and it also produces a matching table definition with column types and sizes estimated from your actual data, for example VARCHAR(50) instead of a generic VARCHAR(255) that wastes space or a TEXT column that is too coarse.
Who it's for
Developers, data analysts, and anyone migrating a spreadsheet export into a relational database who does not want to write an ETL script for a one-time or occasional load. It is useful for seeding a local dev database from sample data, moving a small dataset between systems, or turning an exported report into a table you can query with SQL.
How to use it
- Paste your CSV text into the box, or upload a .csv file.
- Set the table name, or let it default from the uploaded filename.
- Pick a SQL dialect: MySQL, PostgreSQL, or SQLite.
- Set how many rows to batch into each INSERT statement.
- Toggle type inference and, if you want it, CREATE TABLE generation.
- Copy or download the generated .sql file.
Good to know
Type inference is a best-effort guess based on the values present in each column and treats a column as text if even one value does not look numeric, which is the safest default but means a column of mostly numbers with one stray label becomes VARCHAR. Very large CSV files are parsed entirely in memory in your browser, so extremely large exports (hundreds of megabytes) may be slow. No file is uploaded to a server; parsing and SQL generation happen entirely on your device.
Frequently asked questions
Does this tool upload my CSV file anywhere?
No. The CSV is read and parsed locally in your browser using the File API, and the SQL is generated on your device. Nothing is sent to a server, which makes this safe to use with CSVs that contain real customer or business data.
How does type inference decide between INT, DECIMAL, and VARCHAR?
For each column, the tool checks every non-empty value: if all of them are whole numbers it uses INT, if all of them are numeric but include decimals it uses DECIMAL sized to the largest number of digits seen, and if any value is not purely numeric it falls back to VARCHAR sized to the longest value in that column, or TEXT if values are long.
What happens to empty cells in the CSV?
An empty cell becomes SQL NULL rather than an empty string or a zero, which is usually what you want for missing data. If you need empty strings instead of NULL for a specific column, you can find and replace that in the generated SQL before running it.
Why would I want smaller INSERT batches instead of one INSERT per row?
Multi-row INSERT statements are dramatically faster to execute than one statement per row because the database parses and plans the query once per batch instead of once per row. Batching in groups of 100 to 1000 rows is a common sweet spot; very large single statements can hit query size or memory limits on some databases.
What is the difference in identifier quoting between the dialects?
MySQL wraps table and column names in backticks, while PostgreSQL and SQLite use double quotes for identifiers that need escaping. This tool applies the correct quoting style automatically based on the dialect you select so the generated SQL runs without syntax errors.
Can I generate just the CREATE TABLE statement without the data?
Yes. Turn on the CREATE TABLE option and you will get the table definition at the top of the output; you can copy just that section if you only need the schema and plan to load the data a different way.