CSV to SQL Converter
Turn a CSV into ready-to-run SQL: a CREATE TABLE with column types inferred from your data, then batched multi-row INSERT statements — written correctly for PostgreSQL, MySQL, SQLite, SQL Server or Oracle.
CSV to SQL Converter
Runs in your browser — nothing you enter is uploaded or stored.
Scratchpad auto-saved
How it works — in four simple steps
No signup and nothing to install — it all runs in your browser.
Add your CSV
Paste it into the left box, press Open file, or drag a .csv file onto it. Sample loads a realistic example.
Set the options
Adjust the options above the boxes — the output updates instantly as you change them.
Check the result
Read the status line: it reports rows, keys and any value that couldn't be represented in SQL.
Copy or download
Copy the SQL or download it as a .sql file. Nothing was uploaded at any point.
Pick the dialect first — quoting, booleans and types all change with it.
Features
Delimiter auto-detection
Comma, semicolon, tab or pipe is sniffed from the first lines — European Excel exports with ; just work.
Header row or not
Use the first row as field names, or treat every row as data with generated column1, column2… names.
Real types, not just strings
Numbers, booleans and empty values are detected — while codes with leading zeros such as 00742 or +44 phone numbers stay text.
Five SQL dialects
PostgreSQL, MySQL, SQLite, SQL Server and Oracle — with the right identifier quoting, boolean literals and column types for each.
Batched INSERTs
Rows are grouped into multi-row INSERT statements (capped at 1,000 for SQL Server) so large imports run fast.
CREATE TABLE included
Column types (INTEGER, DOUBLE, BOOLEAN, DATE, VARCHAR(n)…) are inferred from the actual values.
Private by design
Parsing and conversion run in your browser with JavaScript — your data is never uploaded, logged or stored.
About the CSV to SQL Converter
Every database has a bulk loader (COPY in PostgreSQL, LOAD DATA in MySQL, .import in SQLite, BULK INSERT in SQL Server), but they need file access on the server and exact settings. A SQL script is the portable alternative: paste it into any client — psql, MySQL Workbench, DBeaver, SSMS, a migration file or a seed script — and it runs.
The converter parses the CSV (RFC 4180, delimiter auto-detected), types each value, and infers one SQL type per column from all its values: whole numbers become INTEGER (or BIGINT past 2,147,483,647), decimals DOUBLE PRECISION/DOUBLE/FLOAT, true/false BOOLEAN (or TINYINT(1), BIT, NUMBER(1)), ISO dates DATE, ISO date-times TIMESTAMP/DATETIME/DATETIME2, and text VARCHAR(50), VARCHAR(255) or TEXT depending on the longest value. Codes with leading zeros stay text, so ZIP codes and IDs aren't damaged.
Each dialect gets its own syntax: identifier quoting ("…", `…`, […]), boolean literals, N'…' Unicode strings for SQL Server, Oracle's INSERT ALL … SELECT 1 FROM DUAL and DATE '…' literals, and SQL Server's 1,000-row limit per VALUES list. Single quotes inside values are doubled, so names like O'Brien can't break the statement.
Examples
An employee export with an apostrophe in a name, a leading-zero code, a boolean, a date and an empty value.
emp_code,name,dept,salary,full_time,hired
00017,Siobhan O'Brien,Engineering,98000,true,2021-04-12
00042,Rahul Deshpande,Design,76500.5,true,2022-09-01
00103,Mei Chen,Support,,false,2025-02-17CREATE TABLE "employees" (
"emp_code" VARCHAR(50),
"name" VARCHAR(50),
"dept" VARCHAR(50),
"salary" DOUBLE PRECISION,
"full_time" BOOLEAN,
"hired" DATE
);
INSERT INTO "employees" ("emp_code", "name", "dept", "salary", "full_time", "hired") VALUES
('00017', 'Siobhan O''Brien', 'Engineering', 98000, TRUE, '2021-04-12'),
('00042', 'Rahul Deshpande', 'Design', 76500.5, TRUE, '2022-09-01'),
('00103', 'Mei Chen', 'Support', NULL, FALSE, '2025-02-17');This output was produced by the converter on this page with table name employees (PostgreSQL) — load it with the “Employees” preset above and change any option to see the effect.
How CSV maps to SQL
| In CSV | Becomes in SQL |
|---|---|
Header joined | column "joined" (quoted for the dialect) |
42, 7 | INTEGER |
98.5 | DOUBLE PRECISION · DOUBLE · FLOAT · REAL · BINARY_DOUBLE |
true / false | BOOLEAN TRUE/FALSE · MySQL TINYINT(1) 1/0 · SQL Server BIT |
2026-10-21 | DATE (SQLite: TEXT) |
O'Brien | 'O''Brien' |
| Empty cell | NULL |
| Text ≤ 50 / ≤ 255 / longer | VARCHAR(50) / VARCHAR(255) / TEXT |
Things that trip people up
- Types are a starting point. VARCHAR(50) is chosen from the data you pasted; if future rows will be longer, widen it. Add PRIMARY KEY and NOT NULL constraints before running in production.
- Huge files. Scripts with hundreds of thousands of rows work but are slow to execute. For big loads use the database's bulk loader with the CREATE TABLE generated here.
- Dates in other formats. Only ISO dates (2026-10-21) are typed as DATE. 21/10/2026 is ambiguous and stays text — convert it in a spreadsheet first.
- Reserved words as headers. Columns named order, group or user are quoted, so they work — but you'll have to quote them in every query. Renaming them is kinder.
CSV vs SQL at a glance
| Property | CSV | SQL |
|---|---|---|
| Specification | RFC 4180 (2005) | ISO/IEC 9075 + vendor dialects |
| File extension | .csv | .sql |
| Media type | text/csv | application/sql (RFC 6922) |
| Data types | text only — every cell is a string | per column: INTEGER, DOUBLE, BOOLEAN, DATE, VARCHAR … |
| Comments | No | Yes -- and /* */ |
| Nesting | None (flat rows) | None (tables) |
- CSV: Fields containing a comma, a double quote or a line break must be wrapped in double quotes, and a quote inside is written twice ("").
- SQL: Identifier quoting differs by database: "double quotes" in PostgreSQL, SQLite and Oracle, `backticks` in MySQL, [brackets] in SQL Server.