CSV to SQL Converter

Generate CREATE TABLE + INSERT statements from CSV — typed, escaped, dialect-aware.

Samples:

Options

CSV Input

SQL Output
3 rows
6 cols

CREATE TABLE IF NOT EXISTS "my_table" (
  "id" INTEGER,
  "name" TEXT,
  "email" TEXT,
  "active" BOOLEAN,
  "score" REAL,
  "created_at" TIMESTAMP
);

INSERT INTO "my_table" ("id", "name", "email", "active", "score", "created_at") VALUES (1, 'Ada Lovelace', 'ada@example.com', TRUE, 9.5, '2024-01-15');
INSERT INTO "my_table" ("id", "name", "email", "active", "score", "created_at") VALUES (2, 'Alan Turing', 'alan@example.com', TRUE, 8.0, '2024-02-20');
INSERT INTO "my_table" ("id", "name", "email", "active", "score", "created_at") VALUES (3, 'Grace Hopper', NULL, FALSE, 9.8, '2024-03-10');
Inferred types: id:INTEGER · name:TEXT · email:TEXT · active:BOOLEAN · score:REAL · created_at:TIMESTAMP

About

Turn CSV data into SQL. Optionally emit CREATE TABLE with inferred column types (INTEGER, REAL, BOOLEAN, TEXT, TIMESTAMP), then INSERT statements — individual or multi-row. Values are correctly typed (numbers and booleans unquoted, strings escaped, empty cells become NULL). Choose ANSI/SQLite, PostgreSQL, or MySQL identifier quoting. Everything runs in your browser; nothing is uploaded.

    Examples

    Convert with headers to one-INSERT-per-row

    Input
    name,age,city
    Alice,30,Berlin
    Bob,25,Paris
    Output
    INSERT INTO "table_name" ("name", "age", "city") VALUES ('Alice', 30, 'Berlin');
    INSERT INTO "table_name" ("name", "age", "city") VALUES ('Bob', 25, 'Paris');

    First row is used as column names; strings are quoted, numbers are not, and each row becomes a separate INSERT statement.

    Convert without headers using multi-row INSERT

    Input
    Alice,30,Berlin
    Bob,25,Paris
    Output
    INSERT INTO "table_name" ("col1", "col2", "col3") VALUES
    ('Alice', 30, 'Berlin'),
    ('Bob', 25, 'Paris');

    Without headers, the tool generates col1/col2/col3 column names. Multiple rows are combined into a single multi-row INSERT for efficiency.

    About this tool

    CSV to SQL Converter turns tabular data from a CSV file into SQL INSERT statements. It is the fastest way to get a spreadsheet, a data export, or a pasted table into a relational database without manual formatting or a spreadsheet-to-SQL workflow.

    Powered by PapaParse, it handles quoted fields containing commas, escaped quotes, and mixed line endings. Numbers and booleans are written unquoted, strings are escaped with doubled single quotes, and empty cells become NULL so the resulting SQL is clean and portable.

    How to use

    1. Paste your CSV

      Drop a CSV or TSV into the input panel, or load a sample to see the output immediately.

    2. Configure options

      Toggle 'First row is header' to use the first row as column names; pick ANSI, MySQL, or no identifier quoting; choose one-INSERT-per-row or multi-row INSERT.

    3. Copy or download

      Click Copy to grab the SQL, or Download to save the file. The output is ANSI-compatible by default but the MySQL style is selectable.

    Use cases

    Importing a spreadsheet into a database

    Copy data from Excel or Google Sheets, paste it as CSV, and get clean INSERT statements ready to run against your database.

    Seeding a test database

    Generate SQL inserts from a CSV fixture so your test suite can populate tables reproducibly.

    Converting a data export from one tool

    Many tools export to CSV by default. Convert to SQL to load the same data into a relational database.

    Common mistakes

    Mistake:Assuming a header row is always present.

    Fix:Many CSV exports include headers as the first row. Toggle 'First row is header' off only if the data genuinely has no column names — otherwise your first data row becomes the column names in the SQL.

    Mistake:Leaving an empty cell as an empty string when NULL is expected.

    Fix:The tool converts empty cells to NULL by default (since empty strings are not the same as SQL NULL). Verify this is what your schema expects — a NOT NULL column will reject NULL inserts.

    Mistake:Using ANSI quoting for MySQL or vice versa.

    Fix:ANSI SQL uses double quotes for identifiers ("col"); MySQL uses backticks (`col`). Pick the matching dialect for your database or the INSERT will be a syntax error.

    Frequently asked questions

    References & standards