CSV to SQL Insert Generator

Paste or upload a CSV file and get ready-to-run INSERT INTO statements, with an optional CREATE TABLE statement. Column names and data types — including numbers, booleans, and dates — are detected automatically. Everything runs in your browser, so your data is never uploaded anywhere.

1. Add your data

Accepts comma, semicolon, or tab-separated values. Up to 5,000 rows are converted per run.

2. Configure output

Splits your data into multiple statements of this size — unrelated to the 5,000-row total limit above.

3. Your SQL

-- Your generated SQL will appear here.

About this tool

An SQL INSERT statement is how you load rows into a database table one batch at a time. Writing them by hand from a spreadsheet export is slow and error-prone — string values need quoting, quotes inside text need escaping, and numbers or booleans must stay unquoted. This tool reads your CSV, works out each column's type, and writes the statements for you, batched so large files don't produce one unmanageable statement.

Choosing a SQL dialect

MySQL, PostgreSQL, SQLite, and SQL Server agree on the basics of INSERT syntax but differ in how identifiers are quoted and how duplicate rows are handled. MySQL uses backticks around names and INSERT IGNORE to skip duplicates. PostgreSQL and SQLite use double quotes, and PostgreSQL skips duplicates with ON CONFLICT DO NOTHING while SQLite uses INSERT OR IGNORE. SQL Server wraps identifiers in square brackets and has no direct equivalent for ignoring duplicates inline — that needs a MERGE statement, which is outside the scope of this tool. Generic mode sticks to widely supported ANSI SQL if you're not sure which database you'll target.

How data types are detected

Each column is sampled and classified as an integer, decimal, boolean, date, time, datetime, or text, based on every non-empty value in that column matching the same pattern. Dates are recognized in common formats like 2024-01-15 or 01/15/2024, and timestamps that combine a date and time are detected separately from plain dates. When Include CREATE TABLE is checked, the same detection also picks a reasonably sized column type for the target dialect — for example, integers are sized as SMALLINT, INT, or BIGINT depending on the largest value found, rather than defaulting everything to the largest type available.

Frequently asked questions

Does my CSV data get uploaded anywhere?
No. Parsing and SQL generation both happen in your browser with JavaScript; nothing is sent to a server.
Is there a row limit?
Yes, up to 5,000 rows are converted in a single run to keep the page responsive. If your file has more, only the first 5,000 rows are used, and the tool tells you so before you generate anything.
Can it generate the table structure, not just the data?
Turn on Include CREATE TABLE to get a CREATE TABLE IF NOT EXISTS statement (or its SQL Server equivalent) ahead of the INSERT statements, with column types inferred from your data.
What happens to quotes and special characters in my text?
Single quotes inside text values are automatically doubled so the generated SQL stays valid — you don't need to escape anything yourself.
My file wasn't recognized as CSV. Why?
The tool checks the first line for a comma, semicolon, or tab. If none are found, it assumes the file isn't delimited data and shows a warning instead of guessing.