Convert CSV to SQL
INSERT statements
for any database.
Free CSV to SQL converter. Generate CREATE TABLE and INSERT statements for MySQL, PostgreSQL, SQLite, SQL Server or Oracle. Auto-infers column types, handles NULL values, supports batch inserts. Runs in your browser.
Three steps to database-ready INSERT statements.
Drop your .csv file. CSVShift reads the headers and samples up to 200 rows per column to infer the correct SQL data type — INT, BIGINT, DECIMAL, BOOLEAN, DATE, TIMESTAMP or VARCHAR — without any manual configuration.
Enter the target table name (pre-filled from your filename), select the SQL dialect (MySQL, PostgreSQL, SQLite, SQL Server or Oracle), and choose whether to include a CREATE TABLE statement. The table name is automatically escaped for the selected dialect.
Preview the first 30 lines of generated SQL, then copy it to your clipboard for immediate use in a query client (DBeaver, pgAdmin, MySQL Workbench) or download the .sql file to run from the command line.
Understanding the generated SQL output before running it.
CSVShift generates two types of SQL statements. The CREATE TABLE statement defines the table schema — one column per CSV header, with data types inferred from the actual values. The INSERT INTO statements populate the table with your data, one row per CSV row.
Batch inserts group multiple rows into a single INSERT statement — for example INSERT INTO table VALUES (row1), (row2), (row3)…. This is significantly faster than one INSERT per row for large datasets because it reduces the number of round-trips to the database and allows the engine to optimize the write in a single operation.
All string values are properly escaped — single quotes are doubled, not backslash-escaped — following the SQL standard. For SQL Server, string literals are prefixed with N to support Unicode characters. Table and column names are quoted with the appropriate quoting style for each dialect: backticks for MySQL, double quotes for PostgreSQL and SQLite, square brackets for SQL Server.
Common database workflows that start with a CSV file.
Development and staging databases need realistic seed data. Converting a CSV export from production (or a sample dataset) to SQL INSERT statements is the fastest way to populate a fresh schema with meaningful test data.
When migrating data between systems, the source often exports as CSV. Converting to SQL INSERT statements produces a format that any database can import via its command-line client without requiring file system access or special import privileges.
Business data maintained in Excel spreadsheets often needs to be moved into a relational database. Exporting the spreadsheet as CSV and converting to SQL creates a repeatable, auditable import process rather than a one-off manual entry.
Data analysts who prefer SQL over Excel often convert CSV datasets to a local SQLite or DuckDB table for querying. CSVShift generates the table schema automatically — no need to define column types manually before running queries.
What each setting produces in the generated SQL.
| Option | Values | What it produces |
|---|---|---|
| SQL dialect | MySQL · PostgreSQL · SQLite · SQL Server · Oracle | Controls identifier quoting (backticks vs double-quotes vs brackets), string prefixes (N'' for SQL Server), data type names (INT vs INTEGER vs NUMBER) and CREATE TABLE syntax variations. The output is immediately runnable in the selected database without modification. |
| CREATE TABLE | Include · Exclude | Include generates CREATE TABLE IF NOT EXISTS with inferred column types. Exclude generates INSERT statements only — for importing into an existing table that already has the correct schema. |
| INSERT mode | Batch · Single | Batch groups multiple rows into one INSERT — up to 10x faster for large datasets. Single generates one INSERT per row — easier to debug and required by some tools that process SQL line by line. SQL Server always uses single inserts for maximum compatibility. |
| Empty values | NULL · Empty string | NULL converts blank CSV cells to SQL NULL — semantically correct for missing data and allows IS NULL queries. Empty string inserts '' — required when the column has a NOT NULL constraint or when downstream code distinguishes between null and empty. |
Other free converters on CSVShift you might need.
SQL generated entirely
in your browser. No upload.
CSVShift generates SQL INSERT statements entirely in JavaScript in your browser. Your CSV data — which may contain sensitive business records, customer data or financial information — is never transmitted to any server. The SQL is built in memory and either copied to your clipboard or downloaded directly.
The type inference engine samples each column to determine the most appropriate SQL type — avoiding the common mistake of importing everything as VARCHAR and losing query performance on numeric and date columns.
mysql -u user -p database < file.sql. 2) Use MySQL's native LOAD DATA INFILE command — faster for very large files but requires file system access on the server.df = pd.read_csv('file.csv'); df.to_sql('table', engine, if_exists='replace', index=False). For a no-code browser solution that also generates the CREATE TABLE schema, use CSVShift.