CSV to SQL
Turn a CSV file into a SQL script you can run. The header row gives the column names, values are typed so numbers and booleans are not quoted while codes like 01234 stay text, empty cells become NULL, strings are escaped for your database, and rows are grouped into multi-row INSERTs inside a transaction, with an optional CREATE TABLE inferred from the data.
- Runs in your browser
- No sign-up
- Free to use
How to use CSV to SQL
- Paste CSV or open a .csv file.
- Choose the database and table name.
- Pick the batch size, CREATE TABLE and transaction options.
- Copy or download insert.sql and run it.
CSV to SQL features
Four databases
MySQL/MariaDB, PostgreSQL, SQLite and SQL Server syntax.
Typed values
Numbers, booleans and dates written natively; leading zeros kept.
Correct escaping
Quotes doubled, MySQL backslashes handled, N-strings for SQL Server.
CREATE TABLE
Column types, NOT NULL and an id primary key inferred from data.
Fast loading
Multi-row INSERTs within each database’s limits, in a transaction.
Local
Generated in your browser.
When to use CSV to SQL
- Loading a spreadsheet export into a database.
- Creating seed data for development from a CSV file.
- Migrating a list from Excel into an application table.
- Preparing an SQL script for a database without CSV import access.
CSV to SQL FAQ
How are column types chosen?
From the values: whole numbers become INT or BIGINT, decimals floating-point, true/false BOOLEAN or BIT, ISO dates date-time types, and text VARCHAR sized from the longest value or TEXT.
What happens to empty cells?
They are inserted as NULL, and their columns are created without NOT NULL.
Why are some numbers quoted?
Values with leading zeros, such as postcodes, would lose the zero as numbers, so they are kept as text.
Is the output safe to run?
Every value is an escaped literal, so data cannot break out of its string. Review generated scripts and use a transaction, as provided.
Should my application insert data like this?
No. Applications should use prepared statements with parameters; generated scripts are for loading and seeding data.
How large can the CSV be?
Up to 50,000 rows in the browser. Use the database’s bulk import (LOAD DATA, COPY, .import) for larger files.
From CSV to INSERT statements
Databases offer fast bulk loaders for CSV, but they are not always available: managed databases may block file access, migrations need SQL scripts, and seed data often lives in version control as SQL. Generating INSERT statements from the CSV gives a portable script that any client can run.
The CSV is parsed with proper quoting and delimiter detection, and the header row provides column names. Because every CSV value is text, typing decides how values are written in SQL: numbers and booleans without quotes, dates in the database’s format, and everything else as an escaped string. Values whose meaning would change as numbers, such as codes with leading zeros, stay text.
The SQL is written by the same generator as the JSON to SQL Insert tool, so both produce identical, tested output. Identifiers are quoted for each dialect, strings have their quotes doubled, MySQL’s backslash escapes are respected, and SQL Server strings carry the N prefix for Unicode.
Rows are grouped into multi-row INSERT statements, which load many times faster than one statement per row, while respecting limits such as SQL Server’s maximum of 1,000 rows per VALUES list. The script is wrapped in a transaction, so an error part-way through leaves the table unchanged.
The optional CREATE TABLE is inferred from the data: integer ranges choose INT or BIGINT, text lengths choose VARCHAR sizes, columns without empty cells are NOT NULL, and a unique integer id becomes the primary key. Review it before production use, and add indexes and constraints your application needs.