CSV → SQL INSERT Generator
Convert CSV data into SQL INSERT statements ready to load into a table.
Category: Converters
When to use?
Use it to load Excel/CSV data into a database, to make test dummy data as SQL, or to move CSV exports into another database.
How to use
- Paste CSV data with column names in the first line.
- Specify the table name and delimiter.
- Copy the generated SQL INSERT statements and run them in the database.
Input Explanation
The CSV first line is used as column names (header). It supports comma/semicolon/tab delimiters and quoted values.
Calculation Basis
It converts each row into an INSERT, leaving numbers unquoted and wrapping strings in single quotes with internal quotes escaped. Options group rows into one INSERT or treat empty values as NULL.
Usage Examples
- Migrate data - Move CSV-exported data into another database.
- Generate test data - Make dummy data for development/testing as SQL INSERT statements.
- Seed initial data - Load initial data organized in Excel into a table at once.
Examples
- id,name → INSERT INTO "users" ("id", "name") VALUES (1, 'John');
- With the group-rows option, one INSERT generates multiple VALUES
Cautions
- Malformed source data can cause parsing errors or broken output.
- A mismatched encoding standard or complex nested data may break or drop the structure.
Guides
Value type handling
Numeric values are left unquoted; strings are wrapped in single quotes. A single quote inside a string is escaped to two per SQL standard.
Choose the INSERT form
Make a separate INSERT per row, or group rows into one INSERT … VALUES. The grouped form is efficient for bulk inserts.
FAQ
How are numbers and strings distinguished?
Numeric values are left unquoted; others are wrapped in single quotes.
What if a value contains a quote?
A single quote inside a string is doubled per SQL standard.
How are empty values handled?
Enable "treat empty as NULL" to convert blanks to NULL.
Which databases can use it?
It quotes column names with double quotes, so it works in standard SQL like PostgreSQL, SQLite, Oracle. MySQL uses backticks, so switch quotes or use ANSI_QUOTES mode.
Related Tools
- CSV ↔ JSON Converter - Convert CSV and JSON array data bidirectionally.
- CSV ↔ Markdown Table Converter - Convert CSV data into a Markdown table, or a Markdown table back into CSV.
- JSON → Table Converter - Convert a JSON object array into a rows-and-columns table and export to CSV.
- SQL Formatter - Neatly align SQL queries by keywords and clauses.
- SQL IN Clause Generator - Convert a line list into a SQL IN (…) form.
- URL Encode / Decode - Encode text into URL-safe form (%XX) or decode an encoded URL back to text.