CSV to SQL Converter

Convert CSV data into SQL INSERT statements for quick database import

CSV Input

Paste your CSV data or upload a file

Options

SQL Output

Generated SQL INSERT statements

Data Type Detection

Integers (123, -45)INT
Decimals (12.34, -5.67)DECIMAL(10,2)
Dates (2024-01-15)DATE
DateTime (2024-01-15 10:30:00)DATETIME
Boolean (true, false, yes, no)BOOLEAN
Text (any string)VARCHAR

About CSV to SQL Converter

Convert CSV to SQL INSERT Statements

This tool converts CSV (Comma-Separated Values) data into SQL INSERT statements, making it easy to import data into databases. It automatically detects data types and generates properly formatted SQL code.

Features

  • Automatic data type detection
  • CREATE TABLE statement generation
  • Batch INSERT statements
  • Transaction wrapping
  • CSV file upload support
  • Proper value escaping
  • Copy to clipboard
  • Download as .sql file
  • Handles quoted values
  • NULL value support

How to Use

  1. Paste CSV data or upload a CSV file
  2. Set the target table name
  3. Configure options (batch size, CREATE TABLE, transaction)
  4. Click "Convert to SQL"
  5. Copy or download the generated SQL
  6. Run the SQL in your database

CSV Format Requirements

  • First row must contain column headers
  • Values separated by commas
  • Use quotes for values containing commas
  • Empty values are converted to NULL
  • Escape quotes by doubling them ("")

Batch Size

Large datasets are split into multiple INSERT statements based on the batch size. This prevents query size limits and improves performance. Typical batch sizes: 100-1000 rows.

Database Compatibility

The generated SQL is compatible with most SQL databases including MySQL, PostgreSQL, SQLite, and SQL Server. Minor syntax adjustments may be needed for specific database features.

Use Cases

  • Importing spreadsheet data to database
  • Migrating data between systems
  • Creating test data for development
  • Populating lookup tables
  • Database seeding

Important Note

Always review the generated SQL before running it in production. Data type inference is based on sample values and may not be perfect. Consider adding primary keys, indexes, and constraints as needed for your specific use case.