Convert CSV to SQL INSERT statements directly in your browser. Paste CSV or open a file, choose MySQL, PostgreSQL, SQLite or SQL Server, review column types, and optionally generate CREATE TABLE. Copy the SQL or download a .sql file without uploading your data.
Leading zeros and numbers outside supported precision stay text. The word NULL stays text. Empty quoted and unquoted CSV fields follow the same empty-field setting. Types can be changed after conversion.
This tool generates SQL only; it does not connect to a database. Review types and encoding, back up your database, and test the script before importing. SQLite may round numeric decimals; choose Text for exact storage. MySQL text output assumes a UTF-8 connection and table.
Use this free CSV to SQL converter to turn spreadsheet exports into SQL INSERT statements. Generate a script for MySQL, PostgreSQL, SQLite or SQL Server without sending your CSV data to a server.
With headers enabled, the CSV below supplies the column names:
id,name,postal_code
1,Alice,00123
2,O'Brien,00456
For PostgreSQL, the generated script includes:
CREATE TABLE "csv_data" (
"id" BIGINT,
"name" TEXT,
"postal_code" TEXT
);
INSERT INTO "csv_data" ("id", "name", "postal_code")
VALUES
(1, 'Alice', '00123'),
(2, 'O''Brien', '00456');
Identifiers are quoted for the selected database: backticks for MySQL, double quotes for PostgreSQL and SQLite, and brackets for SQL Server. Apostrophes in text are escaped. SQL Server uses Unicode string literals and NVARCHAR(MAX); MySQL uses LONGTEXT and UTF-8 hexadecimal expressions for text containing backslashes or control characters.
Automatic detection considers all data rows, not just the preview. It recognizes signed 64-bit integers, fixed-point decimals, true/false booleans and valid YYYY-MM-DD dates. Leading-zero codes, scientific notation, whitespace-padded numbers and values beyond supported numeric precision stay text. You can override a column to Text, Integer, Decimal, Boolean or Date. Invalid overrides stop conversion rather than silently changing values.
Decimals use a combined precision of at most 38 digits and at most 30 decimal places. SQLite may store numeric decimals as approximate floating-point values: choose Text when exact representation matters. Text preserves numeric spelling, including trailing zeros. Empty fields can become NULL or empty strings; the literal word NULL remains text. Quoted and unquoted empty fields are treated alike.
Each record must contain the same number of fields. Headers must be nonempty and unique, ignoring case. Without headers, columns are named column_1, column_2 and so on. Quoted commas, escaped quotes and multiline fields are supported. Physically empty CSV lines are skipped; a quoted empty record ("") is preserved even in a single-column file. Whitespace and fields containing spaces are preserved.
CREATE TABLE does not add primary keys, indexes or database-specific constraints. If your table already exists, disable CREATE TABLE and match its schema. Use a UTF-8 connection and table for MySQL. Keep batches within database limits; SQL Server supports at most 1,000 row values per INSERT. Large files are limited by browser memory, and large text fields may exceed database packet limits. NUL characters are rejected.
The tool only generates a script: it never runs SQL or connects to your database. Review the output, back up your data, and test imports before production use.