CSV to SQL Converter (INSERT and CREATE TABLE)

Data Tools

Paste or drop a CSV and get CREATE TABLE and INSERT statements for your database.

Options
CSV (first row = column names)
SQL

Processed in your browser. A copy of each run is saved to your past runs so you can reopen it. Privacy

About

What the CSV to SQL Converter does

The CSV to SQL Converter turns a CSV file into SQL you can run: a CREATE TABLE with a column for each header and an inferred type (integer, decimal, boolean, date, timestamp or text), followed by INSERT statements in batches. It writes PostgreSQL, MySQL, SQLite or SQL Server syntax, quotes names that need it, escapes values safely and writes empty cells as NULL. It never runs any SQL.

Steps

How to use it

  1. 1Paste the CSV or upload a file; the first row must hold the column names.
  2. 2Choose the database, the table name and the rows per INSERT.
  3. 3Press Generate SQL, check the column types, and copy or download the .sql file.

Example

A real run

Input

sku,name,price,in_stock,added
TX-1001,Lone Star Mug,14.99,true,2026-11-20
TX-1002,O'Brien Tote,22.50,false,2026-11-21
CA-2001,Golden Gate Print,35.00,true,2026-11-18
NY-3001,Subway Map Poster,28.00,true,
FL-4001,Gulf Coast Candle,19.95,false,2026-11-19

Output

CREATE TABLE products (
  sku TEXT,
  name TEXT,
  price NUMERIC,
  in_stock BOOLEAN,
  added DATE
);

INSERT INTO products (sku, name, price, in_stock, added) VALUES
  ('TX-1001', 'Lone Star Mug', 14.99, TRUE, '2026-11-20'),
  ('TX-1002', 'O''Brien Tote', 22.50, FALSE, '2026-11-21'),
  ('CA-2001', 'Golden Gate Print', 35.00, TRUE, '2026-11-18'),
  ('NY-3001', 'Subway Map Poster', 28.00, TRUE, NULL),
  ('FL-4001', 'Gulf Coast Candle', 19.95, FALSE, '2026-11-19');

Prices become NUMERIC, in_stock BOOLEAN and added DATE; the apostrophe in O'Brien is doubled and the empty date becomes NULL.

Options

Every setting, and when to use it

Database
Sets identifier quoting ("name", `name` or [name]), type names such as TEXT, NVARCHAR(MAX) or DATETIME2, and how booleans are written. SQL Server is limited to 1,000 rows per INSERT, as the server itself requires.
Override types
Types are inferred from the first 1,000 rows. Values such as ZIP codes with leading zeros are kept as text automatically; write zip:text or qty:integer to force a type.
Rows per INSERT
One INSERT per row is easiest to read and debug; 500 or 1,000 rows per statement loads much faster. Every batch is a separate statement ending with a semicolon.
CREATE TABLE, NULLs and quoting
Turn off CREATE TABLE when the table exists. Empty cells become NULL rather than empty strings. Quote all identifiers when column names might clash with reserved words.

Good to know

Common problems and limits

Up to 50 MB of CSV. Column names are lowercased, spaces become underscores and other punctuation is removed.

Text is escaped by doubling single quotes (and backslashes for MySQL); review generated SQL before running it, especially from files you did not create.

To tidy SQL you have, use the SQL Formatter; to inspect the CSV first, use the CSV Viewer.

Audience

Who uses it

  • DevelopersTurn a spreadsheet into seed data or a migration for a development database.
  • Data analystsLoad a one-off CSV into a database where bulk-import commands are not available to you.
  • QA engineersCreate repeatable test fixtures from CSV files kept alongside the tests.

FAQ

Frequently asked

How do I import a CSV into PostgreSQL, MySQL or SQLite directly?

PostgreSQL: COPY products FROM '/path/products.csv' WITH (FORMAT csv, HEADER), or \copy from psql. MySQL: LOAD DATA INFILE 'products.csv' INTO TABLE products FIELDS TERMINATED BY ',' IGNORE 1 LINES. SQLite: .import --csv products.csv products. SQL Server Management Studio has an Import Flat File wizard.

When should I use INSERT statements instead of a bulk import?

Use INSERTs for small and medium files, for seed data you keep in version control, and when you cannot access the database server's file system. For millions of rows, bulk loaders such as COPY and LOAD DATA are many times faster.

How are column types chosen?

Each column is checked across the first 1,000 rows: all whole numbers become integer, numbers with decimals decimal, true/false boolean, YYYY-MM-DD date and ISO date-times timestamp; anything else is text. Numbers with leading zeros stay text, so ZIP codes and IDs keep their zeros.

Are quotes and apostrophes in values handled?

Yes. Every text value is written inside single quotes with any single quote doubled, so O'Brien becomes 'O''Brien'. MySQL also has its backslashes escaped. Values are never pasted into SQL unescaped.

Why does SQL Server stop at 1,000 rows per INSERT?

SQL Server allows at most 1,000 rows in a single INSERT … VALUES statement, so batches are capped there for that dialect. Other databases accept larger batches.

Is my data sent anywhere?

No. The SQL is generated in your browser and nothing is executed. A copy of each run is saved to your past runs so you can reopen it.

Automation: an MCP tool csv_to_sql(csv, dialect, table) → sql and an n8n node are planned for this tool.

All data tools →
GuideWorking with big CSV files in and out of Excel →Excel stops at 1,048,576 rows and quietly changes ZIP codes, long IDs and dates. How to split, merge and convert big CSV files without losing data.
Built and maintained by Radhika SinghLast updated Questions: hello@operativez.ai