# CSV to SQL

> CREATE TABLE and INSERT statements from CSV for MySQL, PostgreSQL, SQLite or SQL Server. Runs entirely in your browser — nothing is uploaded.

Source: https://toffeekit.com/tools/csv-to-sql

**Category:** [Data](https://toffeekit.com/category/data) · **Price:** Free · **Runs:** in your browser, nothing is uploaded

Open the tool: https://toffeekit.com/tools/csv-to-sql

**Also useful for:** csv to sql, sql insert, create table, mysql, postgresql, sqlite, sql server, import csv

## What you can do

- **Load a CSV into PostgreSQL** — Typed columns, quoted names and batched INSERTs ready for psql. ([open with this preset](https://toffeekit.com/tools/csv-to-sql?preset=postgres))
- **Make a MySQL import script** — Backtick-quoted names and properly escaped strings for MySQL. ([open with this preset](https://toffeekit.com/tools/csv-to-sql?preset=mysql))

## How it works

1. Paste your CSV, drop a file or click Open.
2. Pick the Database and type a Table name.
3. Choose Rows per INSERT and switch CREATE TABLE, Detect column types and Empty cells as NULL on or off.
4. Copy the SQL or click Save to download a .sql file.

## FAQ

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

Paste the CSV or open the file, pick your database and table name, and the tool writes one INSERT per batch of rows. Turn on CREATE TABLE to get the table definition too.

### How are column types chosen?

Each column gets the narrowest type that fits every value: INT or BIGINT for whole numbers, DECIMAL for decimals, BOOLEAN for true and false, DATE or TIMESTAMP for ISO dates, and text otherwise. Turn off Detect column types to make every column text.

### Why do some numbers stay as text?

Values with leading zeros, such as ZIP codes like 02134, and numbers longer than 15 digits are kept as quoted text so nothing is lost or rounded.

### How are quotes and special characters escaped?

Single quotes are doubled, which every database accepts. For MySQL, backslashes are doubled too, and SQL Server strings with non-English characters get the N prefix.

### How many rows can one INSERT statement hold?

MySQL, PostgreSQL and SQLite accept large multi-row INSERTs. SQL Server allows at most 1,000 rows per VALUES list, so batches are capped there.

### Is CSV to SQL free and private?

Yes. It's free with no sign-up or limits, and it runs entirely in your browser, so your files are processed on your device and never uploaded. It works on phones and computers alike.

## Privacy

CSV to SQL runs entirely in your browser. Your files and text are processed on your device and are never uploaded.

## Related tools

- [CSV to JSON](https://toffeekit.com/tools/csv-to-json) — Turn CSV rows into JSON objects.
- [JSON to CSV](https://toffeekit.com/tools/json-to-csv) — Flatten JSON into a CSV you can open in Excel.
- [XML ⇄ JSON](https://toffeekit.com/tools/xml-json-converter) — Convert XML to JSON and back.
- [CSV Cleaner](https://toffeekit.com/tools/csv-cleaner) — Trim cells, drop empty rows, remove duplicates.
- [Delimiter Converter](https://toffeekit.com/tools/csv-delimiter-converter) — Switch between comma, semicolon, tab and pipe.
- [CSV Viewer](https://toffeekit.com/tools/csv-viewer) — Open a CSV as a sortable, searchable table.

