Knowledge Mark G
Hire Me

Free developer tool

CSV to SQL Converter

Turn a CSV file into CREATE TABLE and INSERT statements for MySQL, PostgreSQL, SQL Server or SQLite.

  • No sign-up
  • Instant results
  • Runs in your browser

CSV input

Delimiter (found: Comma)

4 rows × 9 columns - detected types

idintegernametextemailtextcitytextziptextplantextmonthly_spenddecimalactivebooleansigned_update
1Smith, Jane[email protected]Boston02134Pro49.00true2026-01-05
2Oliver O'Neil[email protected]London-Starter9.99true2026-02-11
3Lukas Becker[email protected]Berlin10115Team199.00false2026-03-02
4Emma "Em" Ross[email protected]Austin78701Pro49.00true2026-04-19

SQL

1 KB

Fewer rows per statement = smaller transactions.

customers.sql
CREATE TABLE "customers" (
  "id" INT,
  "name" TEXT,
  "email" TEXT,
  "city" TEXT,
  "zip" TEXT,
  "plan" TEXT,
  "monthly_spend" NUMERIC,
  "active" BOOLEAN,
  "signed_up" DATE
);

INSERT INTO "customers" ("id", "name", "email", "city", "zip", "plan", "monthly_spend", "active", "signed_up") VALUES
  (1, 'Smith, Jane', '[email protected]', 'Boston', '02134', 'Pro', 49.00, TRUE, '2026-01-05'),
  (2, 'Oliver O''Neil', '[email protected]', 'London', NULL, 'Starter', 9.99, TRUE, '2026-02-11'),
  (3, 'Lukas Becker', '[email protected]', 'Berlin', '10115', 'Team', 199.00, FALSE, '2026-03-02'),
  (4, 'Emma "Em" Ross', '[email protected]', 'Austin', '78701', 'Pro', 49.00, TRUE, '2026-04-19');

Column types detected: id: integer, name: text, email: text, city: text, zip: text, plan: text, monthly_spend: decimal, active: boolean, signed_up: date.

From spreadsheet to database in one step

Paste a CSV and get a ready-to-run SQL script: an optional CREATE TABLE with a column type for each field, followed by multi-row INSERT statements. Column types are detected from the data - whole numbers become INT (or BIGINT when they need it), decimals become DECIMAL or NUMERIC, true/false becomes BOOLEAN or BIT, ISO dates become DATE, and everything else becomes text sized to fit.

Written for your database

Each database quotes names and values differently, and the script follows the one you pick. MySQL quotes identifiers with backticks and needs backslashes escaped; PostgreSQL and SQLite use double quotes; SQL Server uses square brackets and N’…’ strings so non-English text survives. Single quotes inside values are doubled for all of them, so a name like O’Brien cannot break the statement.

Batches and limits

Rows are grouped into INSERT statements of 500 by default. SQL Server refuses more than 1,000 rows in a single VALUES list, so the converter caps it there. Smaller batches mean smaller transactions if you are loading into a busy database.

When to use bulk load instead

For hundreds of thousands of rows, the database’s own loader is faster: COPY in PostgreSQL, LOAD DATA INFILE in MySQL, BULK INSERT in SQL Server, .import in SQLite. For anything up to tens of thousands, a script like this is simpler and works through any client. Need JSON instead? Use the CSV to JSON converter.

Questions people ask

How do I convert a CSV file to SQL INSERT statements?+

Open or paste the CSV, choose your database and a table name, and the INSERT statements are generated as you type. Download them as a .sql file or copy them into your client.

Which databases are supported?+

MySQL and MariaDB, PostgreSQL, Microsoft SQL Server and SQLite. Each gets its own identifier quoting, string escaping and boolean values.

How are column types chosen?+

From the values in the column: whole numbers, decimals, true/false, ISO dates and date-times are recognised. Anything mixed becomes text. Review the CREATE TABLE before running it - you know your data better than any guess.

What happens to empty cells?+

With 'Empty cells as NULL' on, they become NULL. Off, empty text cells become empty strings, while empty number and date cells still become NULL because '' is not a valid number.

Is it safe with apostrophes and quotes in my data?+

Yes. Single quotes are doubled, which is the SQL standard escape, and MySQL backslashes are escaped too.