convert-csv.com logo convert-csv.com

Convert CSV to SQL

Generate CREATE TABLE and INSERT statements from CSV for multiple SQL dialects.

100% Secure - your files are processed in your browser and never sent to a server.
Drop your file hereor click to browseSupports CSV, TSV, or TXT files (.csv, .tsv, .txt) (Max 100MB)

**CSV to SQL conversion** is the process of transforming Comma-Separated Values data into Structured Query Language statements for importing tabular data into relational databases. SQL is the standard language for managing data in relational database management systems, as defined by the ISO/IEC 9075 standard. This tool produces CREATE TABLE statements (with appropriate data type inference) and INSERT statements from CSV data. It supports four SQL dialects: MySQL, PostgreSQL, SQLite, and Microsoft SQL Server, each with their specific syntax for string quoting, NULL handling, and data types. You can configure a table name, choose the batch size for INSERT statements (100, 500, 1000, or 5000 rows per statement), and toggle whether to generate the CREATE TABLE header. The parser infers column data types by analyzing the first 100 rows: columns containing only integers become INTEGER, decimal numbers become REAL/VARCHAR, and everything else becomes VARCHAR/TEXT. The output includes proper escaping for single quotes and backslashes, and handles NULL values correctly. All processing runs locally in your browser, which is critical because CSV data being converted to SQL often contains sensitive records.

How to use the Convert CSV to SQL tool

  1. Load your CSV data: Drag and drop your CSV file, choose a file from your file explorer, or paste CSV data directly into the paste area.
  2. Configure SQL output: Enter a table name, choose a SQL dialect (MySQL, PostgreSQL, SQLite, or MSSQL), and toggle whether to generate a CREATE TABLE statement.
  3. Set input options: Select the input delimiter, toggle header row, and choose a batch size for INSERT statements (100, 500, 1000, or 5000 rows).
  4. Convert to SQL: Click the "Convert Data" button to generate CREATE TABLE and INSERT statements from your CSV.
  5. Export results: Copy the SQL output to your clipboard or download it as a file.

Frequently asked questions

Which SQL dialects does the tool support?
Four dialects: MySQL (backtick quoting, AUTO_INCREMENT), PostgreSQL (double-quote quoting, SERIAL), SQLite (flexible types), and Microsoft SQL Server (bracket quoting, IDENTITY). Each dialect follows the ISO/IEC 9075 SQL standard with vendor-specific extensions.
How does the tool infer column data types?
The parser analyzes the first 100 rows to detect: INTEGER (all values are integers), REAL (values contain decimals), and VARCHAR (mixed or text data). The CREATE TABLE statement uses the inferred types, following the SQL data type hierarchy defined in the SQL standard.
What batch sizes are available for INSERT statements?
You can choose from 100, 500, 1000, or 5000 rows per INSERT statement. Larger batches produce fewer statements but may be harder to debug if data issues arise. Batch inserts are a standard optimization technique for bulk data loading.
Does the tool escape single quotes in string values?
Yes. The parser correctly escapes single quotes (' → ''), backslashes, and other special characters according to the selected SQL dialect's escaping rules. This prevents SQL injection vulnerabilities and ensures data integrity during import.
Can I generate only INSERT statements without CREATE TABLE?
Yes. Toggle off the CREATE TABLE option to generate only INSERT statements. This is useful when importing into an existing database table. The INSERT syntax follows the ISO SQL standard for data manipulation language (DML).

Related tools