Skip to content

CSV to SQL

Turn a CSV export into INSERT statements, with column types inferred.

Quick Tool Overview

The CSV to SQL converter turns a spreadsheet export into INSERT statements: the header row becomes the column list, quotes are escaped, blanks become NULL, and column types are decided from the whole column rather than cell by cell.

What it does
Generates SQL INSERT statements from CSV
You give it
CSV with a header row
You get back
INSERT statements, optionally with a CREATE TABLE
Best for
Loading a spreadsheet or export into a database
Developer Tools Free, unlimited use No sign-up Runs in your browser

About the CSV to SQL

Loading a spreadsheet export into a database usually means either an import wizard you do not trust or statements you write by hand. This generates the statements: the header row becomes the column list, each data row becomes a set of values.

The escaping and typing are where hand-written SQL goes wrong. Single quotes inside a value are doubled, which is the standard escape and works in every major database. Column types are decided from the whole column rather than cell by cell, so one blank does not turn a numeric column into text. Blank cells become NULL rather than empty strings. You can emit one statement per row, or a single batched insert that loads far faster, plus an optional CREATE TABLE.

Key features of the CSV to SQL

RFC 4180 reading

A quoted field containing commas, line breaks or doubled quotes is read as one value, which is where naive splitting corrupts a row.

Types from the whole column

One blank cell does not turn a numeric column into text, because the type is decided from every value at once.

Blanks become NULL

An empty cell is written as NULL rather than an empty string, which is almost always what a database import should mean.

Safe column names

Spaces and punctuation in a header become underscores and a leading digit is prefixed, so the statement parses.

Batched or single

One multi-row INSERT for a fast bulk load, or a statement per row when you need to run them selectively.

How to use the CSV to SQL

  1. 1

    Paste your CSV

    Include the header row — it becomes the column names.

  2. 2

    Name the table

    Set the target table and choose your SQL dialect for the right quoting.

  3. 3

    Choose the statement style

    One INSERT per row for readability, or a single batched insert for a fast load.

  4. 4

    Run the SQL

    Add the CREATE TABLE first if the table does not exist yet.

Frequently asked questions

The reader follows RFC 4180, so a quoted field containing commas, line breaks or doubled quotes is read as one value rather than being split.

Reviews of the CSV to SQL

What people who use the CSV to SQL think of it. Reviews come from visitors and are posted as written.

No ratings yet

Yours would be the first.

  • 5 0 reviews rated 5 stars
  • 4 0 reviews rated 4 stars
  • 3 0 reviews rated 3 stars
  • 2 0 reviews rated 2 stars
  • 1 0 reviews rated 1 star

Write a review

Used this tool? Your rating helps the next person decide.

Your rating

Plain text only — links, email addresses and HTML are not accepted. Your name and review are shown publicly; nothing else is collected. See the privacy policy.

0 reviews

Newest first

No reviews yet

Be the first to rate the CSV to SQL. It takes half a minute and no account.

Write the first review

More developer tools