CSV to SQL

Generate SQL CREATE TABLE and batched INSERT statements from CSV, TSV or PSV data for standard, PostgreSQL, MySQL or SQLite — locally in your browser.

  • Runs locally in your browser
  • No upload required

Capabilities

  • Drag and drop
  • Local file intake
  • Download result

Try it

Read locally in your browser; never uploaded.

A cell equal to this becomes an unquoted SQL NULL.

Paste delimited text or choose a file, then run the tool. Everything happens in your browser.

Supported formats

Input
text/csv, text/plain
Output
text
Files
Local file intake and drag/drop

Privacy

Runs entirely in your browser. Your input is never uploaded, stored, or sent to a third party.

Processing
In your browser
Privacy level
Browser only

Generated 2 SQL statement(s) for 2 row(s) across 2 column(s).

How it works

  • Parsed the delimited text per RFC 4180 and sanitised the table/column identifiers.
  • Inferred each column's SQL type conservatively for the optional CREATE TABLE.
  • Quoted identifiers and escaped strings per the chosen dialect, then batched the INSERTs.
  • A cell equal to the configured NULL token becomes an unquoted NULL; every other value is quoted as a string.

Methodology

  1. Parse per RFC 4180 and sanitise the table and column identifiers to conservative tokens.
  2. Infer each column's SQL type (integer/number/boolean/date/text) for the optional CREATE TABLE.
  3. Quote identifiers and escape string literals per dialect (doubled quotes for standard/PostgreSQL/SQLite, backslash escaping and backtick identifiers for MySQL), then batch INSERTs.

Usage

  1. Paste delimited text or choose a local file.
  2. Choose the SQL dialect, table name, batch size and NULL token.
  3. Optionally include a CREATE TABLE, then copy or download the statements.

Examples

These are examples, not current values: they use fixed inputs, while the interactive tool computes live results in your browser.

Generate PostgreSQL INSERTs

jsonSelect to copy
{
  "text": "id,name\n1,Ada\n2,Alan",
  "delimiterMode": "comma",
  "delimiter": ",",
  "firstRowHeader": true,
  "dialect": "postgresql",
  "tableName": "people",
  "batchSize": 2,
  "nullToken": "NULL",
  "createTable": true,
  "quoteIdentifiers": true
}

Limitations

Safety first

INSERT statements modify data. Inspect the generated SQL, check the table and column names and take a backup before running anything against a real database.

Dialect-aware quoting

Identifiers and string literals are quoted per the selected dialect so a column named with a space, or a value containing an apostrophe, does not break the statement.

Frequently asked questions

Will this run my SQL?
No. It only generates statements in your browser; you review and run them yourself.
How are quotes escaped?
Standard/PostgreSQL/SQLite double single quotes; MySQL uses backslash escaping. Identifiers use double quotes except MySQL, which uses backticks.

Sources

  1. RFC 4180 — Common Format and MIME Type for Comma-Separated Values (CSV) Files — IETF
  2. PostgreSQL Documentation — SQL Syntax: Lexical Structure — PostgreSQL Global Development Group
  3. MySQL 8.0 Reference Manual — String Literals — Oracle