CSV to SQL Converter
Convert CSV data into SQL CREATE TABLE and INSERT statements with dialect-specific syntax, auto type detection, and batch inserts.
CSV Input
SQL Output
CSV to SQL Converter
Convert CSV data into SQL CREATE TABLE and INSERT statements with dialect-specific syntax, auto type detection, and batch inserts.
Features
- Parse CSV (with quoted fields and embedded commas) and emit valid INSERT statements
- SQL dialect selector: MySQL, PostgreSQL, SQLite, SQL Server (handles identifier quoting and string escaping per dialect)
- Single quotes in values are escaped per dialect (`O'Brien` → `O''Brien` standard / `O\'Brien` MySQL)
- Type inference: integer / decimal / boolean / date / string; emit values without quotes for non-strings
- Empty cells become NULL when "treat empty as NULL" is enabled
- Batch INSERT mode emits one statement with multiple value rows for efficiency
How to use
- Paste your CSV data into the input area or load sample data.
- Configure the table name, delimiter, and quote character if needed.
- Select your target SQL dialect (MySQL, PostgreSQL, SQLite, or SQL Server).
- Choose the output mode: CREATE + INSERT, INSERT only, or CREATE only.
- Toggle batch insert, auto-detect types, and NULL for empty values.
- Copy the generated SQL to your clipboard.
Tips & Best Practices
- For production data import, always validate the dialect output against your target database — escape rules differ subtly across MySQL/Postgres/SQLite/SQL Server.
- Reserved-word column names are auto-quoted (`order`, `select`, etc.) so they don't collide with SQL keywords.
- Batch INSERT is ~10× faster than per-row INSERTs for large imports — most databases accept up to ~1000 rows per statement.
- Date parsing accepts ISO 8601 (YYYY-MM-DD) and MM/DD/YYYY. Other formats fall through as strings — you may need to reformat first.
- Embedded quotes inside CSV cells must already be properly escaped (double-doubled) in the input; the tool then re-escapes for SQL.
FAQ
Which SQL dialects are supported?
MySQL, PostgreSQL, SQLite, and SQL Server. Each dialect generates proper syntax including identifier quoting (backticks, double quotes, or brackets) and dialect-specific column types.
How does auto type detection work?
The tool analyzes all values in each column to determine the best SQL type. It detects integers, floating-point numbers, booleans (true/false/yes/no), dates (ISO format), and falls back to text for everything else.
What does batch insert do?
Instead of generating separate INSERT statements for each row, batch insert groups multiple rows into a single INSERT statement with multiple value tuples. This is much faster for database imports.
How are empty values handled?
When 'NULL for empty' is enabled, empty CSV fields are converted to SQL NULL. Otherwise, empty text fields become empty strings and empty numeric fields become 0.
Is my data private?
All processing happens in your browser. No data is ever sent to any server or third party.