CSV to SQL Converter
Convert CSV to SQL online. Generates a CREATE TABLE with inferred column types plus batched INSERT statements for MySQL, PostgreSQL, SQLite or SQL Server.
What is the CSV to SQL Converter?
The ByteTools CSV to SQL converter turns a spreadsheet export into a complete import script. It reads your header row for column names, scans the data to infer a sensible type for each column — integer, decimal, boolean, date or text — and writes a CREATE TABLE statement followed by batched INSERTs.
- CREATE TABLE with column types inferred from your data
- Batched multi-row INSERT statements
- MySQL, PostgreSQL, SQLite and SQL Server dialects
- Optional auto-increment primary key and IF NOT EXISTS
- Handles quoted fields, embedded commas and newlines
- 100% private — CSV never leaves your browser
How to use the CSV to SQL Converter
- 1
Paste your CSV, or drop a .csv file to load it and name the table from the filename.
- 2
Choose the delimiter, the SQL dialect and how many rows go in each INSERT.
- 3
Toggle IF NOT EXISTS, an auto-increment id column and NULL handling for empty cells.
- 4
Click Generate SQL, then review the inferred types and copy or download the script.
About the CSV to SQL Converter
The ByteTools CSV to SQL converter turns a spreadsheet export into a complete import script. It reads your header row for column names, scans the data to infer a sensible type for each column — integer, decimal, boolean, date or text — and writes a CREATE TABLE statement followed by batched INSERTs.
Choose MySQL, PostgreSQL, SQLite or SQL Server and identifiers, types and boolean literals all follow that engine's rules. Options let you add an auto-increment primary key, use CREATE TABLE IF NOT EXISTS, and decide whether empty cells become NULL or empty strings.
Everything runs 100% locally in your browser with JavaScript, so your CSV is never uploaded or stored. Inferred types are a starting point drawn from the rows you paste — review them before running the script against a real database, and remember generated SQL is for trusted data, not a substitute for parameterised queries.
Frequently asked questions
How do I convert a CSV file to SQL?
Paste or drop your CSV, set the table name and dialect, then click Generate SQL. You get a CREATE TABLE statement with inferred column types followed by INSERT statements for every row, ready to copy or download as a .sql file.
How does it decide each column's data type?
It scans every value in the column. If they are all whole numbers it uses INT or BIGINT, all decimals become a float type, true/false values become a boolean, YYYY-MM-DD values become DATE, and anything else becomes VARCHAR sized to the longest value or TEXT.
Can I import a CSV without a header row?
Yes. Untick 'First row is a header' and the tool names the columns column1, column2 and so on, treating every line as data. Rename them in the generated CREATE TABLE before you run it.
How are empty cells handled?
With 'Empty cells become NULL' on, blank values are written as NULL and the column is declared nullable. Turn it off and blanks stay as empty strings in text columns, which matters when you need to distinguish missing from empty.
Is my CSV uploaded to a server?
No. Parsing and SQL generation happen entirely in your browser with JavaScript. Nothing is transmitted or stored, so exports containing customer or financial data stay private.
Related tools
JSON to SQL INSERT
Convert a JSON array of objects into SQL INSERT statements online. MySQL, PostgreSQL, SQLite and SQL Server quoting with batched multi-row inserts.
SQL INSERT Parser
Convert SQL INSERT statements to CSV or JSON online. Parse quoted strings, NULLs, numbers and multi-row VALUES lists directly in your browser.
SQL Formatter
Format SQL online: uppercase keywords, new lines before SELECT, FROM, WHERE and JOIN, indented AND/OR conditions. One-line minify included. Free and private.
CSV to JSON Converter
Convert CSV to a JSON array of objects online. Header-row detection, comma/semicolon/tab delimiters and pretty-printed output — 100% in your browser.
CSV Viewer & Table
View CSV as a clean HTML table online. Live search filter, row and column counts, delimiter and header options — all processed locally in your browser.