A fast, private CSV to SQL converter
Transforming spreadsheet data into a relational database format is a common task for developers, database administrators, and data analysts. This tool allows you to convert CSV to SQL directly in your web browser. Whether you need to seed a new database, migrate legacy records, or quickly import a dataset, you can generate insert statements from CSV data in seconds.
Because the entire conversion process runs locally on your device, your data is never uploaded to an external server. This guarantees complete privacy and security, allowing you to safely process confidential user data, financial records, or proprietary information without risking exposure.
How automatic type inference works
Writing a schema by hand for a dataset with dozens of columns is tedious. To save time, this tool automatically reads your CSV data and infers the most appropriate SQL data type for each column. It looks at the actual values in your rows (skipping empty cells) and applies the following rules:
- INTEGER: Assigned if every value in the column is a whole number (e.g.,
42,-15). - DECIMAL: Assigned if the values are floating-point numbers or use scientific notation (e.g.,
3.14,-0.5). - BOOLEAN: Assigned if the column contains only
trueorfalse(case-insensitive). - DATE: Assigned if the values match the standard ISO date format (
YYYY-MM-DD). - TEXT / VARCHAR: The fallback type if a column contains mixed data, plain text, or formats that don't match the strict patterns above.
If you choose to generate a CREATE TABLE statement, these inferred types are automatically mapped to the correct syntax for your chosen database dialect.
Supported SQL dialects
Different database engines have unique rules for quoting identifiers (like table and column names), defining data types, and formatting literal values. This tool supports four major dialects to ensure your generated SQL runs without syntax errors:
MySQL: When you convert CSV to MySQL, the tool wraps table and column names in backticks (`). Text columns default to VARCHAR(255), and booleans are written as TRUE or FALSE.
PostgreSQL: Identifiers are wrapped in double quotes ("). Text columns use the TEXT type, which is standard and highly efficient in Postgres. Booleans are natively supported as TRUE or FALSE.
SQLite: Identifiers use double quotes. Because SQLite uses dynamic typing with a restricted set of storage classes, decimals are mapped to REAL, booleans are mapped to INTEGER (outputting 1 or 0), and text uses the TEXT affinity.
SQL Server (T-SQL): Identifiers are wrapped in square brackets ([]). Text columns default to VARCHAR(255), and booleans are mapped to the BIT data type (outputting 1 or 0). Additionally, if a text string contains non-ASCII characters, the tool automatically prefixes it with N (e.g., N'Value') to ensure proper Unicode (NVARCHAR) insertion.
Customizing your SQL output
You can tailor the generated SQL script to match your exact deployment needs using the configuration toggles:
- Table name: Define the exact name of the target table. The tool will automatically apply the correct quoting for your dialect.
- Include CREATE TABLE: If you are building a database from scratch, enable this to generate the schema definition before the insert statements. The tool uses the headers from your CSV as column names.
- Batch inserts: Running thousands of individual
INSERT INTOstatements can be slow. Enabling the batch option groups up to 500 rows into a single CSV to SQL insert statement. This drastically reduces the file size and improves import performance. - Empty cells as NULL: Spreadsheets often contain blank cells. Checking this option ensures that empty strings in your CSV are explicitly written as the
NULLkeyword in SQL, rather than inserting empty strings ('') into your database.
Tips for preparing your CSV data
For the best results, ensure your CSV file has a header row. The tool uses the first row of your data to name the columns in the CREATE TABLE and INSERT statements. If a column header is blank, it will be automatically named column_1, column_2, etc.
If your data contains complex text with commas, newlines, or quotes, ensure the CSV is properly formatted (typically by wrapping the field in double quotes). The tool includes a robust CSV parser that correctly handles escaped quotes and multi-line fields.
If you need to process your data in other formats, you might also find our CSV to JSON or CSV to Excel converters useful. Once your SQL is generated, you can run it through a SQL Formatter if you need to adjust the indentation or casing of the keywords.