What it does
Converts CSV text into SQL import statements in three formats:
- INSERT — batched multi-row
INSERT INTO … VALUES (…), (…);statements, with a configurable rows-per-statement batch size and dialect-aware rules (SQL / MySQL / Postgres). - COPY — a Postgres
COPY … FROM STDIN WITH (FORMAT csv, HEADER true);block ending in the psql\.terminator, payload included. - LOAD DATA — a MySQL
LOAD DATA LOCAL INFILEstatement plus the CSV payload to save as the referenced file.
The first CSV row is the header. Header names are trimmed, sanitized into SQL identifiers (anything outside A–Z a–z 0–9 _ becomes _), de-duplicated deterministically (id, id → id, id_2), and empty headers become col<N>. With type inference on, fields that look like numbers emit bare and verbatim (007 stays 007, 1e3 stays 1e3) and empty fields emit NULL; with it off, every value is a quoted string. Strings double their single quotes ('O''Brien'); MySQL mode additionally escapes backslashes and control bytes. 100% client-side.
How to use it
- Paste CSV into CSV — a sample is prefilled. The first row must be the header.
- Set the Table name and pick a Format: INSERT, COPY, or LOAD DATA.
- For INSERT, optionally pick the Dialect, the Rows / statement batch size, and toggle Type inference. For LOAD DATA, set the referenced File name.
- The SQL renders live on the right with the row count in the header.
- Copy it, or Download as
import.sql.
Examples
Typed INSERT — table users, sample input →
INSERT INTO "users" ("id", "name", "email", "country") VALUES
(1, 'Ada Lovelace', 'ada@example.com', 'UK'),
(2, 'Alan Turing', 'alan@example.com', 'UK'),
(3, 'Hamilton, Margaret', 'margaret@example.com', 'US');
Empty fields become NULL — id,note with rows 1, and 2,hi → (1, NULL) and (2, 'hi').
Header sanitizing — User Name,user-id → columns "User_Name", "user_id".
COPY block — same input in COPY format →
COPY "users" ("id", "name", "email", "country") FROM STDIN WITH (FORMAT csv, HEADER true);
id,name,email,country
1,Ada Lovelace,ada@example.com,UK
…
\.
Good to know
- Private: conversion is local — nothing leaves the browser.
- Numeric text passes through verbatim, so large integers never lose precision and
1e3is not rewritten as1000. - COPY quoting always follows Postgres rules and LOAD DATA always follows MySQL rules, regardless of the INSERT dialect setting — each format matches its engine’s native syntax.
- Run LOAD DATA output with
mysql --local-infile=1; the payload after the statement is the file to save. - Postgres INSERT output also works for SQLite in most cases; pick SQL for the conservative baseline.
- Related tools: JSON to SQL INSERT, JSON ↔ CSV Converter, SQL Playground.