Turn your CSV data into ready-to-run SQL in seconds
Paste a CSV file (or upload one) and this tool spits out SQL INSERT statements you can run straight against any database — MySQL, PostgreSQL, SQLite, or SQL Server. No scripting, no manual column mapping, no wasted afternoon.
How to convert CSV to SQL
- Paste or upload your CSV — drop the file into the tool, or paste the raw text directly.
- Set a table name — this becomes the table referenced in every
INSERTstatement. - Choose your SQL dialect — MySQL, PostgreSQL, SQLite, and SQL Server all have slight differences in quoting and data types. Pick the one that matches your database.
- Copy or download — click Copy to grab the SQL, or download it as a
.sqlfile ready to import.
Worked example: CSV input → SQL output
Say you export a contacts list from a spreadsheet and get this CSV:
id,name,email,age
1,Alice,[email protected],29
2,Bob,[email protected],34
3,Carol,[email protected],41
The tool reads the header row, auto-detects that id and age are integers (not strings), and produces:
CREATE TABLE contacts (
id INT,
name VARCHAR(255),
email VARCHAR(255),
age INT
);
INSERT INTO contacts (id, name, email, age) VALUES (1, 'Alice', '[email protected]', 29);
INSERT INTO contacts (id, name, email, age) VALUES (2, 'Bob', '[email protected]', 34);
INSERT INTO contacts (id, name, email, age) VALUES (3, 'Carol', '[email protected]', 41);
String columns get single-quoted; numeric columns stay unquoted. Quoted CSV fields (values that contain commas or newlines wrapped in ") are handled correctly — the parser strips the wrapping quotes before writing the SQL value.
How to do this in Python (without the tool)
If you prefer to script the conversion, Python's csv module makes it straightforward:
import csv
table = 'contacts'
with open('contacts.csv', newline='') as f:
reader = csv.DictReader(f)
for row in reader:
cols = ', '.join(row.keys())
vals = ', '.join(
v if v.lstrip('-').isdigit() else f"'{v}'"
for v in row.values()
)
print(f'INSERT INTO {table} ({cols}) VALUES ({vals});')
This is good for automation pipelines but adds zero type-detection beyond the isdigit check. The online tool does more inference (floats, dates, booleans) without any code on your end.
How to do this in JavaScript (Node.js)
const fs = require('fs');
const lines = fs.readFileSync('contacts.csv', 'utf8').trim().split('\n');
const [headerLine, ...dataLines] = lines;
const cols = headerLine.split(',');
dataLines.forEach(line => {
const vals = line.split(',').map(v =>
isNaN(v) ? `'${v}'` : v
);
console.log(`INSERT INTO contacts (${cols.join(', ')}) VALUES (${vals.join(', ')});`);
});
Works fine for simple CSVs. For quoted fields that contain commas (e.g. "Smith, John"), you'll need a proper CSV parser like PapaParse.
How the converter works
The tool runs entirely in your browser. When you paste CSV, a client-side parser splits the data on commas and line breaks while respecting quoted fields and escaped characters. It then inspects every value column-by-column to decide the SQL data type: INT, FLOAT, DATE, BOOLEAN, or VARCHAR. Finally it renders the CREATE TABLE and INSERT INTO statements using the dialect rules you chose. Nothing leaves your machine.
When to use this tool — and when not to
| Good fit | Look elsewhere |
|---|---|
| One-off data imports into MySQL, PostgreSQL, SQLite, or SQL Server | Millions of rows — use a LOAD DATA INFILE or COPY command directly in your database for speed |
| Seeding a dev or test database from a spreadsheet export | Sensitive production credentials in the CSV — even though nothing is uploaded, keep PII off shared machines |
| Quickly turning a Google Sheets download into database seed data | Complex relational imports across multiple tables — those need a migration tool like Flyway |
| Checking what schema a CSV would map to before writing migrations | CSVs with complex nested data — consider converting to JSON first (see our JSON Beautifier for the next step) |
Tips for cleaner SQL output
- Use a clean header row — column names become SQL identifiers, so avoid spaces.
first_nameis safer thanfirst name. - Consistent date formats help the type detector.
2024-01-15(ISO 8601) is recognised reliably;15/01/24may be treated as a string. - Empty cells become
NULLin the output — check that your table schema allows nulls in those columns. - If your CSV came from Excel, watch for BOM characters (
\uFEFF) at the start of the file — paste into a text editor first to strip them if the first column name looks garbled.
Working with the output in other formats
Sometimes SQL isn't the final destination. If you need to clean or inspect the intermediate data as JSON first, our JSON Validator and JSON Viewer can help you catch structure problems before import. For YAML-based config files that reference the same data, try the JSON to YAML Converter.
Bottom line: paste your CSV, grab the SQL, and load your data — no installs, no sign-up, and nothing uploaded. Give the tool above a try.