Skip to content
Tezmy Tools

CSV to SQL Converter

Turn a CSV file into CREATE TABLE and INSERT statements

3 rows, 5 columns: id BIGINT, name TEXT, score NUMERIC, active BOOLEAN, joined DATE

Runs in your browser. Nothing is uploaded.

About the CSV to SQL Converter

Loading a spreadsheet into a database usually starts with writing a CREATE TABLE and a long list of INSERT statements. This converter does both from a CSV. The first row gives the column names, which are cleaned so they are safe SQL names. The tool looks at the data to guess integer, decimal, boolean, date and text types, quotes text safely and writes empty cells as NULL. Choose PostgreSQL, MySQL, SQLite or SQL Server, set how many rows go in each INSERT, and copy or download the script. The CSV is read in your browser and nothing is uploaded, so private data stays on your device.

Updated October 2026

How to use the CSV to SQL Converter

  1. 1Paste your CSV with a header row in the first line.
  2. 2Type the table name and choose your database.
  3. 3Set how many rows go into each INSERT statement.
  4. 4Choose whether to include CREATE TABLE and to guess types.
  5. 5Copy or download the SQL and run it in your database tool.

What the script contains

The CREATE TABLE statement lists each column with a type that suits the chosen database. For example a whole number becomes BIGINT in PostgreSQL and INTEGER in SQLite, and text becomes TEXT or NVARCHAR(MAX) in SQL Server. Identifiers are quoted in the style of each database: backticks for MySQL, double quotes for PostgreSQL and SQLite, and brackets for SQL Server.

The INSERT statements list all columns and group several rows into one statement, which is faster than one statement per row. Choose a smaller batch if your database or tool limits the statement size.

Numbers need care when columns hold identifiers. A column of zip codes like 02134 is kept as text because a leading zero would be lost in an integer. A column with a mix of numbers and words is text too. If you disagree with a guess, turn off type guessing, load everything as text and change the types afterwards with ALTER TABLE.

Before you run it

  • Check the guessed types, especially for ids, zip codes and phone numbers.
  • Add a primary key and indexes after the data loads.
  • Make sure the table name does not clash with an existing table.
  • Run the script inside a transaction so you can roll back.
  • Test with the first few rows before loading everything.

Related tools

Clean up the file first with the CSV Delimiter Changer or remove unneeded columns with the CSV Column Remover. If you want JSON for an API instead, the CSV to JSON Converter fits, and the SQL Formatter will tidy a long script. Converting from Excel? Export the sheet as CSV, or use the Excel to JSON Converter.

Features

  • PostgreSQL, MySQL, SQLite and SQL Server
  • Column types guessed from the data
  • Safe quoting of text and apostrophes
  • Empty cells written as NULL
  • Batched multi-row INSERTs
  • Clean column names, duplicates renamed
  • Private, runs in your browser

Frequently asked questions

How do I import a CSV into a database with SQL?

Convert it to INSERT statements with this tool, then run the script in your SQL client. Larger files are better loaded with the database's own import command.

How are column types chosen?

If every value in a column is a whole number, it is an integer. Numbers with decimals become decimal, true/false become boolean, ISO dates become date or datetime and anything else is text.

What happens to values like 007 or phone numbers?

Values with leading zeros are kept as text so the zeros are not lost. Phone numbers with plus signs or spaces are also text.

How are quotes escaped?

A single quote inside text is doubled, which is the standard SQL way, so O'Neil is written as 'O''Neil'.

Which delimiter does it expect?

The tool detects commas, semicolons, tabs and pipes automatically, and understands quoted fields with commas inside.

Is there a size limit?

There is no fixed limit, but very large files can be slow in the browser. For millions of rows use your database's bulk loader.

Is the data uploaded?

No. It stays in your browser.

Related tools