CSV to SQL INSERT Converter
Paste a CSV and get ready-to-run INSERT statements: auto-detected delimiter, five SQL dialects with each one's correct quoting, CREATE TABLE with inferred types and configurable row batching. RFC 4180-compliant parser with quotes, escapes and embedded newlines.
| name | age | city | active |
|---|---|---|---|
| Ana | 30 | Madrid | true |
| Luis | 25 | Barcelona | true |
| Smith, John | 41 | Boston | false |
CREATE TABLE `my_table` (
`name` TEXT,
`age` INTEGER,
`city` TEXT,
`active` INTEGER
);
INSERT INTO `my_table` (`name`, `age`, `city`, `active`) VALUES
('Ana', 30, 'Madrid', 1);
INSERT INTO `my_table` (`name`, `age`, `city`, `active`) VALUES
('Luis', 25, 'Barcelona', 1);
INSERT INTO `my_table` (`name`, `age`, `city`, `active`) VALUES
('Smith, John', 41, 'Boston', 0);3 rows · 3 INSERT · 0.4 KB
Built by
Miguel Ángel Colorado Marin (MACM)
Built by
Miguel Ángel Colorado Marin (MACM)
Full-Stack Developer · Guadalajara, España
I develop web apps, digital tools and full projects — from design to deployment.
Loading test data into a database is a daily chore, and it usually starts with a CSV pasted somewhere. This tool turns it into SQL you can run right away. The parser follows RFC 4180 (the actual CSV standard): it honors quoting, doubles inner quotes and accepts newlines inside a field. The generator adapts the output to the chosen dialect: backticks in MySQL, double quotes in PostgreSQL/SQLite/ANSI and brackets in SQL Server; numbers are emitted unquoted, empty fields become NULL, true/false become native boolean literals where applicable, and strings get correct single-quote escaping. CREATE TABLE types are inferred by inspecting every value of each column. Verified with a test bank covering the RFC plus real execution of the generated SQL on SQLite.
Features
- ✓Five dialects: MySQL, PostgreSQL, SQLite, SQL Server and ANSI SQL
- ✓RFC 4180 parser: quoted fields, escaped double quotes and embedded newlines
- ✓Optional CREATE TABLE with per-column inferred types
- ✓Auto-detected or forced delimiter: comma, semicolon, tab or pipe
- ✓Empty fields become NULL, numbers stay unquoted and booleans use native literals
How to convert a CSV to SQL?
- 1
Paste or load the CSV
Type the content directly or load a .csv/.tsv/.txt file from your device.
- 2
Check the parsing
The preview shows the detected columns and the first rows; ragged rows trigger a warning.
- 3
Pick dialect and options
Select the database engine, the table name, whether to add CREATE TABLE, and how many rows go per INSERT.
- 4
Copy or download the SQL
Copy the statements to the clipboard or download them as a .sql file ready to import.
Frequently asked questions
How are fields with commas, quotes or newlines handled?
The parser implements RFC 4180 in full: a quoted field may contain commas and newlines, and an inner double quote is escaped by doubling it (""). The generated SQL escapes single quotes in turn so the INSERT is safe (O'Neil → 'O''Neil').
Which types are inferred in the CREATE TABLE?
Each full column is analyzed: if all values are integers it becomes INTEGER (BIGINT on PostgreSQL), decimals become REAL, true/false/t/f/yes/no map to the dialect's native boolean (BOOLEAN on PostgreSQL, 1/0 on MySQL), and anything else falls back to TEXT. Empty columns stay TEXT.
Why batch several rows into one INSERT?
It's the difference between importing 100,000 rows in seconds or hours: each individual statement carries parse and commit overhead in most engines. The single multi-VALUES INSERT is the standard way to speed up bulk loads. You can pick 1 row per INSERT if your engine doesn't support it or to debug row by row.
Related tools
Embed CSV to SQL INSERT Converter on your site
Add CSV to SQL INSERT Converter to any web page with a simple iframe. Free, with attribution to miguelacm.es.
<iframe
src="https://miguelacm.es/embed/csv-to-sql-insert"
width="100%"
height="700"
frameborder="0"
title="CSV to SQL INSERT Converter — miguelacm.es"
></iframe>View embed in new tab →