deftools.io Developer Tools

🗄️ CSV to SQL INSERT

Convert CSV data into SQL INSERT statements. Pick a table name, choose MySQL, PostgreSQL, SQLite or SQL Server quoting, and export seed scripts.

0 rows
0 statements

About this tool

Paste a CSV (with a header row of column names) and the tool emits ready-to-run INSERT statements you can use to seed a database. It parses quoted fields the way spreadsheets export them — so a value like "Bob, Jr." stays one column, and an embedded quote is written as "".

Example input:

name,email,role
Alice,alice@example.com,admin
"Bob, Jr.",bob@example.com,user

produces (MySQL, multi-row):

INSERT INTO users (name, email, role)
VALUES
  ('Alice', 'alice@example.com', 'admin'),
  ('Bob, Jr.', 'bob@example.com', 'user');

Value detection: integers and decimals are emitted unquoted; true/false become 1/0 on MySQL/SQLite/SQL Server and TRUE/FALSE on PostgreSQL; empty cells become NULL; everything else is single-quoted with ' escaped as ''. Pick the dialect to control identifier quoting (` for MySQL, " for Postgres/SQLite, [] for SQL Server).

FAQ

Are the generated statements safe to run blindly?

They are syntactically valid for the chosen dialect and string-escape safe against quote injection, but always review the output before running it against a production database — the tool does not know your schema, so it cannot guarantee types, constraints, or foreign keys will accept the values.

Why are my numbers not wrapped in quotes?

Numeric-looking values (integers and decimals) are emitted as bare literals so they land in numeric columns. If a value is a phone number or ZIP code that you want treated as text, wrap that cell in quotes in the CSV and prefix with a single quote — or just import into a text column.

What happens to rows with the wrong number of columns?

Rows shorter than the header are padded with NULL; rows longer than the header have the extra cells dropped. A warning appears under the output when this happens. The header row defines the column count.

Does this support UPDATE or INSERT … ON CONFLICT?

No — it generates plain INSERT statements only (single-row or multi-row VALUES). For upserts, generate the INSERTs and then edit the trailing clause to match your dialect (e.g. add ON CONFLICT … DO UPDATE for PostgreSQL).

Copied!