UTILS.
Private by default
🗄

CSV to SQL INSERT Generator

Generate CREATE TABLE and escaped INSERT statements from CSV with type inference.

Your files stay on this device

Files are processed in your browser, never uploaded. The site downloads code and assets to run the tools. No accounts or trackers.

Use Download to save this tool as one HTML file for offline use.

Privacy →
output

About this tool

CSV to SQL is a free, in-browser generator that converts a pasted CSV into SQL statements: an optional CREATE TABLE with inferred column types plus one escaped INSERT per row. It all happens on your device, so your data is never uploaded.

The tool inspects each column and infers whether it is an integer, decimal, date, or text value, then maps those to the right types and identifier quoting for your chosen dialect — MySQL, PostgreSQL, SQLite, or SQL Server. String values are safely escaped, empty cells become NULL, and numeric cells stay unquoted.

Because it runs locally it is a private, offline-friendly way to load spreadsheet data into a database without an import wizard, and you can copy the SQL or download it as a .sql file.

Frequently asked questions

How are column types inferred?
A column is typed as an integer when every non-empty value is a whole number (BIGINT once a value is beyond the 32-bit range), as a decimal when values have fractions (DECIMAL with exactly the precision and scale needed in MySQL and SQL Server, NUMERIC in PostgreSQL, REAL in SQLite), as a date when every value matches YYYY-MM-DD (DATETIME or TIMESTAMP if any value includes a time), and as text otherwise. A column containing a value with a leading zero, such as 007 or 02134, stays text so the zeros are kept, and numbers too long for the dialect's numeric types also stay text. Digits are copied as written, without rounding. Blank cells become NULL.
What changes between dialects?
Identifier quoting and type names differ: MySQL uses backticks and INT/VARCHAR, PostgreSQL and SQLite use double quotes (SQLite favours INTEGER/REAL/TEXT), and SQL Server uses square brackets with NVARCHAR. Text columns with values longer than 255 characters become TEXT (LONGTEXT in MySQL for very long values, NVARCHAR(MAX) in SQL Server). String literals are single-quoted with inner quotes doubled; MySQL strings also escape backslashes, and SQL Server strings use the N'…' prefix so non-English text is kept.
What CSV conventions are assumed?
Fields are split on your chosen delimiter, double-quoted fields (inner quotes doubled) are parsed so embedded delimiters and line breaks survive, and a byte-order mark at the start is ignored. The first row is used as column names when the header box is ticked (otherwise column1, column2 … are used). In column names, anything other than letters, digits and underscores becomes an underscore, and repeated names get a _2, _3 suffix.
Can I skip the CREATE TABLE?
Yes. Untick the CREATE TABLE option to emit only the INSERT statements — handy when the destination table already exists and you just need the rows.

More tools