CSV to SQL Converter

Generate CREATE TABLE and INSERT statements from CSV for MySQL, PostgreSQL, SQLite or SQL Server, with column types detected for you.

Processed on your device. Files are not uploaded

How to turn CSV into SQL

  1. Paste your CSV

    Paste or type it into the box, or press Try an example.

  2. Choose your database

    PostgreSQL, MySQL, SQLite or SQL Server.

  3. Name the table

    Set the table name the statements will use.

  4. Copy or download

    Run the statements in your database client.

Worked example

This is what CSV to SQL Converter gives for its own sample values. Open the tool above and change anything to try your own.

CSV

id,name,email,active,score
1,Ada Lovelace,ada@example.com,true,9.5
2,Linus Torvalds,linus@example.com,false,7
3,"Hopper, Grace",grace@example.com,true,10
Delimiter
Detect automatically
Table name
my_table
Database
PostgreSQL
Include CREATE TABLE
Yes
Write empty cells as NULL
Yes
Rows per INSERT
1

SQL

CREATE TABLE "my_table" (
  "id" BIGINT,
  "name" VARCHAR(255),
  "email" VARCHAR(255),
  "active" BOOLEAN,
  "score" DOUBLE PRECISION
);

INSERT INTO "my_table" ("id", "name", "email", "active", "score") VALUES (1, 'Ada Lovelace', 'ada@example.com', TRUE, 9.5);
INSERT INTO "my_table" ("id", "name", "email", "active", "score") VALUES (2, 'Linus Torvalds', 'linus@example.com', FALSE, 7);
INSERT INTO "my_table" ("id", "name", "email", "active", "score") VALUES (3, 'Hopper, Grace', 'grace@example.com', TRUE, 10);

About CSV to SQL Converter

Generate a CREATE TABLE statement and INSERT statements from CSV. Column types are guessed from the data, text is escaped properly for the database you chose, and rows can be grouped into multi-row inserts.

FAQs

How are column types chosen?

Whole numbers become integers, decimals become floating point, true or false becomes boolean, and everything else is text. Check them before you run the script.

Are quotes escaped?

Yes. A single quote in a value is doubled, which every database accepts.

Can I start from JSON instead?

Use JSON to SQL Converter.

Related tools