Developer Tools
CSV to SQL INSERT Generator
Generate SQL CREATE TABLE and INSERT statements from CSV data for MySQL, PostgreSQL, SQLite or SQL Server.
How to use
- 1Paste CSV with a header row.
- 2Set the table name and dialect, then copy the SQL.
Frequently asked questions
How are column types chosen?
Each column is checked: all integers become INTEGER, all numbers DECIMAL/REAL, true/false BOOLEAN, everything else text.
Are quotes in values escaped?
Yes. Single quotes are doubled (O'Brien → 'O''Brien'), which is the SQL standard escape.
How are empty cells stored?
Empty cells become NULL rather than an empty string.
Column types are inferred by checking every value, not sampling
For each column, the type-inference step collects every non-empty value in that column and only assigns INTEGER if literally all of them match `^-?\d+$`, only DECIMAL/REAL if all match a decimal pattern, only BOOLEAN if all are true/false — any single value that breaks the pattern falls the whole column back to TEXT (or NVARCHAR(MAX) for SQL Server). This is deliberately conservative: a column that's 999 clean integers and one stray 'N/A' becomes TEXT rather than INTEGER, which avoids generating a CREATE TABLE that would reject real rows on import, at the cost of sometimes under-typing a column you know is numeric (safe to hand-edit the generated DDL in that case).
Dialect choice changes identifier quoting and the escape style, not just keywords
Switching dialects changes how column and table names are quoted — double quotes for PostgreSQL/SQLite, backticks for MySQL/MariaDB, square brackets for SQL Server — which matters the moment a column name collides with a reserved word (`order`, `group`) or contains a space. It also changes string literal prefixing: SQL Server strings get an `N` prefix (`N'text'`) for Unicode correctness, which the other three dialects don't use. Single quotes inside values are escaped by doubling them everywhere (`O'Brien` → `'O''Brien'`), which is the ANSI SQL standard and works across all four dialects.
Batch insert vs. one-statement-per-row is a real trade-off
With 'One INSERT for all rows' on, every row becomes a tuple in a single multi-row `INSERT INTO ... VALUES (...), (...), (...)` statement, which is dramatically faster to execute than one `INSERT` per row when you're loading thousands of records, since most databases parse and plan each statement separately. Turn it off when you specifically want per-row statements — for example, when hand-reviewing a small seed-data diff in version control, where one row per line in the diff is easier to read than one giant multi-line statement.
Worked example: CSV to SQL INSERT Generator
CSV `id,name,score\n1,O'Brien,9.5\n2,,7` with table name `people` and PostgreSQL selected generates: CREATE TABLE "people" ( "id" INTEGER, "name" TEXT, "score" DECIMAL(18,6) ); INSERT INTO "people" ("id", "name", "score") VALUES (1, 'O''Brien', 9.5), (2, NULL, 7); The apostrophe in O'Brien is doubled to stay valid SQL, and the empty `name` cell in row 2 becomes `NULL` rather than an empty string — both exactly what you'd want for a real import.
A blank table name becomes my_table, and empty cells skip the type check
An empty paste produces an empty result, not a create statement. Table name opens on my_table, and if I clear it the name falls back to my_table. The name is quoted for the dialect. PostgreSQL and SQLite use double quotes and double any quote inside the name. MySQL uses backticks. SQL Server uses square brackets. Dialect opens on PostgreSQL. Include CREATE TABLE and One INSERT for all rows both start on. When the column type is chosen, empty cells are ignored, so a column of whole numbers with a few blanks can still be an integer. A column with any non-integer value is not forced into that integer type. The download uses an sql name.
Related tools
- SQL Formatter
Format and beautify SQL queries for PostgreSQL, MySQL, SQL Server, SQLite, BigQuery and more, with uppercase keywords.
- JSON Schema Generator
Generate a JSON Schema (draft 2020-12) from sample JSON — types, nested objects, arrays, required fields and formats like email, date-time and URI.
- String Escape / Unescape
Escape or unescape strings for JavaScript, JSON, HTML, XML, SQL, CSV and regular expressions — quotes, backslashes and newlines handled.
- Web Scraper (No-Code)
Extract data from any web page without coding — tables, links, headings, images, meta tags or anything matching a CSS selector — and export to CSV, Excel or JSON.
- Add Bookmarks to PDF (Table of Contents)
Add clickable bookmarks (an outline / table of contents) to any PDF — nested chapters and sections, or auto-suggested from each page — so readers can jump around in any PDF viewer.
- Word Tables to Excel Converter
Pull every table out of a Word document into an Excel workbook, one sheet per table or all on one sheet. Merged cells stay merged, header rows are kept, and numbers, currencies and percentages typed as text become real numbers you can sum.