CSV to SQL Converter
Turn a CSV into SQL INSERT statements for MySQL, PostgreSQL, SQLite, or SQL Server, right in your browser. Your data stays on your device.
The CSV to SQL Converter runs entirely in your browser. The CSV you paste or drop and the SQL it generates never leave your device and nothing is uploaded to ArrayKit.
Open the SQL Formatter
About CSV to SQL
The CSV to SQL Converter turns a CSV file into ready-to-run SQL. Paste or drop your data, pick a dialect — MySQL, PostgreSQL, SQLite, or SQL Server — and it infers each column's type, quotes the table and column names the way that dialect expects, and escapes every value so single quotes, empty cells, numbers, and booleans come out correct. You get one INSERT per row or a batched multi-row INSERT, plus an optional CREATE TABLE so you can seed a schema from scratch. It is built for developers seeding a dev database, importing a spreadsheet export, or writing a migration who want the SQL generated for them instead of hand-typing thousands of values. The whole conversion happens in your browser, so the CSV you load never leaves your device.
Features
- Generates INSERT statements for MySQL, PostgreSQL, SQLite, and SQL Server
- Infers integer, float, boolean, and text column types from your data
- Quotes identifiers correctly per dialect: `col`, "col", and [col]
- Escapes single quotes and emits NULL for empty or null-like cells
- Optional CREATE TABLE with mapped column types for the chosen dialect
- Batched multi-row INSERT mode for faster bulk loading
- Paste, type, or drop a .csv file — with a header row
- Copy the SQL or download it as a .sql file to run in your client
How to use the CSV to SQL
- Paste your CSV or choose a .csv file — keep the first row as the header
- Pick the target dialect: MySQL, PostgreSQL, SQLite, or SQL Server
- Set the table name and toggle CREATE TABLE on if you need the schema
- Copy the generated SQL or download it as a .sql file
Example
Input
id,name,active
1,O'Brien,true
2,Ada,false
Output
INSERT INTO `my_table` (`id`, `name`, `active`) VALUES (1, 'O''Brien', 1);
INSERT INTO `my_table` (`id`, `name`, `active`) VALUES (2, 'Ada', 0);
The apostrophe in O'Brien is escaped and the booleans become 1 and 0 for MySQL.
Common errors & troubleshooting
- A numeric-looking column like a zip code or id loses its leading zeros. — Values such as 007 are kept as text on purpose so the zeros survive. If you want them stored as numbers, strip the padding in the source CSV first.
- Every value in a column ends up quoted as text when you expected numbers. — A column is only typed as integer or float when every non-empty cell is numeric. One stray value (a dash, N/A, or a label) makes the whole column text — clean that cell to get numeric output.
- Booleans came out as 1 and 0 but you wanted TRUE and FALSE. — Only PostgreSQL emits TRUE / FALSE literals. MySQL, SQLite, and SQL Server use 1 and 0, which is correct for their boolean-style columns — switch the dialect to PostgreSQL for named literals.
- The output looks blank or has the wrong columns after loading a file. — Make sure the first row is a header with a name for every column. A missing or empty header cell is flagged so the SQL is not generated with a nameless column.
Frequently asked questions
- How does the CSV to SQL Converter decide each column's type?
- It scans every non-empty cell in a column. If they are all whole numbers it uses integer, all numeric with a decimal it uses float, all true/false-style tokens it uses boolean, and otherwise text. Zero-padded numbers like 007 stay text so leading zeros are not lost.
- How are single quotes and apostrophes in my data handled?
- String values are wrapped in single quotes and any embedded single quote is doubled ('' ), which is the standard SQL escaping. So O'Brien becomes 'O''Brien' and runs safely across all four dialects.
- What SQL does it generate for empty cells?
- Empty cells and the tokens NULL, NA, and N/A become the SQL keyword NULL rather than an empty string, so your rows insert with genuine nulls instead of blank text.
- Can it create the table as well as insert the rows?
- Yes. Turn on CREATE TABLE and it emits a CREATE TABLE statement with a column type mapped for your dialect, then the INSERTs. MySQL, PostgreSQL, and SQLite use IF NOT EXISTS so the script is re-runnable.
- What is the multi-row INSERT option for?
- By default each row is its own INSERT statement, which is easy to read and diff. Multi-row INSERT groups many rows into one statement with a shared VALUES list, which loads large files faster in MySQL, PostgreSQL, and SQLite.
- Does my CSV get uploaded to generate the SQL?
- No. Parsing and SQL generation run entirely in your browser using JavaScript. The CSV you paste or drop is never sent to a server, so sensitive spreadsheet exports stay on your device.
Related tools
- CSV to JSON — Convert CSV or TSV to JSON with type inference and nested keys, in your browser.
- SQL Formatter — Format SQL for MySQL, PostgreSQL, SQL Server, SQLite, BigQuery and Oracle.
- JSON to CSV — Convert an array of flat JSON objects to CSV.
- CSV to Markdown Table — Convert CSV or TSV data into a Markdown table, with alignment and header options.
- Excel to JSON — Convert an .xlsx or .xls spreadsheet to JSON, with sheet and header options, in your browser.
- JSON to Code — Generate Go, Rust, Python, Java, Kotlin, C# and TypeScript types from JSON.
All ArrayKit tools