CSV to SQL INSERT

Turn a CSV into INSERT statements, with the header row becoming the column list. Pick your dialect and the escaping follows it: identifiers get backticks on MySQL, double quotes on Postgres and SQLite, square brackets on SQL Server. The detail worth knowing about is backslashes — MySQL treats one as an escape character, so it has to be doubled, while Postgres treats it as a literal, so doubling it there would corrupt the value. Both are handled per dialect. Type inference leaves numbers unquoted but keeps anything that only looks numeric as text, so a code like 007 keeps its zeros and a long ID does not get rounded into a float. Empty cells become NULL. For large imports, multi-row mode emits one INSERT with many value tuples, batched to a size you choose. Read the output before running it — it is generated text, not a reviewed migration.

Per-dialect differences

DialectIdentifierBackslash in a string
MySQL / MariaDB`name`Escape character — doubled
PostgreSQL"name"Literal — left alone
SQLite"name"Literal — left alone
SQL Server[name]Literal — left alone

When to use it

  1. Seed a development database from a spreadsheet.
  2. Load a CSV into a table without setting up an import tool.
  3. Generate fixture data for tests from a sample export.
  4. Move data between databases that have no direct import path.
  5. Produce a repeatable INSERT script to commit alongside a schema change.

How to Use

  1. Paste your CSV, or drop files in.
  2. Set the table name and pick your database dialect.
  3. Copy or download the SQL, and read it before running it.

Features

  1. MySQL, PostgreSQL, SQLite and SQL Server
  2. Correct per-dialect identifier and string escaping
  3. Backslash handling that differs by dialect, as it must
  4. Type inference, with codes and long IDs kept as text
  5. NULL for empty cells
  6. Multi-row INSERTs with an adjustable batch size

FAQs

Is my data uploaded?

No. The SQL is generated in your browser. Nothing is sent anywhere, which matters because the CSVs people convert to INSERTs are usually real records.

How are quotes in my data escaped?

A single quote is doubled, which is standard SQL and correct in all four dialects — so O'Brien becomes 'O''Brien'. Identifiers are escaped the same way using each dialect's own quote character.

Why does MySQL need different handling for backslashes?

Because MySQL treats a backslash as an escape character under its default settings, so a literal backslash has to be doubled or the value changes — C:\new would arrive carrying a newline. Postgres has standard_conforming_strings on by default, where a backslash is already literal, so doubling it there would store two where you meant one. The dialect you pick decides which rule applies.

Why is 007 quoted instead of becoming a number?

Because it is a code, not a quantity, and turning it into 7 would destroy it. Only plain numeric forms are left unquoted, and an integer beyond JavaScript's safe range stays text too, which is what stops long IDs and account numbers being silently rounded.

What happens to empty cells?

They become NULL when type inference is on, which is usually right for a database column. Turn inference off and every value is quoted as a string, including empty ones.

Should I use multi-row INSERTs?

For anything beyond a few hundred rows, yes — one statement per row is slow. But one statement containing a hundred thousand rows will exceed what most servers accept, which is why the batch size is adjustable. A few hundred to a thousand rows per statement is a reasonable default.

Is the generated SQL safe to run as-is?

Read it first. The escaping is correct for the dialect you chose, but this tool does not know your schema, your constraints or your column types. Treat it as a draft to review, not a migration someone has signed off.

Technical Details

Two escaping rules decide whether the generated SQL is correct, and they differ by dialect. Doubling a single quote inside a string literal is standard and covers all four dialects offered here. Backslashes are where they diverge: MySQL treats a backslash as an escape character under its default settings, so a literal backslash must be doubled or the value silently changes — a path like C:\new arrives carrying a newline. Postgres is the opposite case, since standard_conforming_strings has been on by default since 9.1 and a backslash is already literal, so doubling it there would store two backslashes where you meant one. Both behaviours are implemented per dialect rather than picking one and hoping. Identifiers are quoted the way each dialect expects — backticks for MySQL, double quotes for Postgres and SQLite, square brackets for SQL Server — and the quote character inside a name is escaped by doubling, which is the rule all four share. Type inference keeps numbers unquoted while leaving anything that merely looks numeric as a string: a leading-zero code like 007 stays text, and an integer beyond the safe range stays text rather than being silently rounded, which is what protects long IDs and account numbers. Empty cells become NULL rather than an empty string, and booleans become 1 and 0 for SQL Server, which has no boolean literal. Multi-row mode emits one INSERT with many VALUES tuples, optionally batched, since a single statement per row is slow for large imports and one statement for a hundred thousand rows exceeds what most servers accept. Everything runs in your browser and nothing is uploaded.

Data & CSV Tools

Data & CSV Tools

  • CSV to Markdown Table
  • CSV to JSON
  • JSON to CSV
  • YAML to JSON
  • CSV Graph Plotter
  • YAML Formatter & Validator
  • XML to JSON
  • Query String to JSON