Skip to main content

CSV to SQL Converter

Convert CSV data with a header row into a CREATE TABLE statement and INSERT statements — infers each column's type (INTEGER/REAL/TEXT), picks MySQL/PostgreSQL/SQLite identifier quoting, and escapes string values.

Input

Sanitized to a valid SQL identifier: letters, digits, underscore — can't start with a digit.

Off generates one INSERT statement per row instead.

Output

SQL output
 
Was this helpful?

Guides

Copy-paste CSV data — a spreadsheet export, a database dump, a quick list you typed by hand — and get back ready-to-run SQL: a CREATE TABLE statement matching your columns, followed by INSERT statements loading every data row. It's the fastest way to seed a new database table from a handful of rows without writing the schema by hand.

How it works

Paste CSV with a header row in the first line. The converter treats that row as your column names and every row after it as data. Parsing follows RFC 4180: fields wrapped in double quotes can contain commas or newlines, and a doubled "" inside a quoted field becomes a literal ".

Type inference looks at every value in a column (ignoring blanks) and classifies it:

  • INTEGER — every non-empty value is a whole number (42, -7).
  • REAL / DECIMAL / NUMERIC — every non-empty value has a decimal point (9.99, -3.5). The exact type name depends on dialect.
  • TEXT / VARCHAR — anything else, including a column that mixes whole numbers and decimals.

An entirely empty column defaults to TEXT. Blank cells become NULL in the generated INSERT statements regardless of column type.

Dialect controls identifier quoting and column type names:

Dialect Identifier quoting INTEGER REAL/decimal TEXT
MySQL `backticks` INT DECIMAL(10,2) VARCHAR(255)
PostgreSQL "double quotes" INTEGER NUMERIC(10,2) TEXT
SQLite "double quotes" INTEGER REAL TEXT

Text values are wrapped in single quotes, with any internal single quote doubled (it's becomes 'it''s') — the standard SQL-92 escaping convention every major database understands.

How to use it

  1. Paste your CSV (with a header row) into the input box.
  2. Set a table name — anything you type is sanitized into a valid identifier automatically (non-alphanumeric characters become underscores, and a name starting with a digit gets a leading underscore).
  3. Pick your target dialect: MySQL, PostgreSQL, or SQLite.
  4. Toggle Batch INSERT to choose between one INSERT statement with multiple VALUES rows (compact, fewer round-trips) or a separate INSERT statement per row (easier to review or partially re-run).
  5. Copy or download the generated SQL.

FAQ

Will it detect the wrong type for my column? If a column mixes formats — some whole numbers, some decimals, or the occasional text label like "N/A" — it falls back to TEXT so no numeric value gets silently rounded or rejected. Clean up mixed columns in your spreadsheet first if you want a numeric column type.

What happens to empty cells? They become NULL in the INSERT statements, regardless of the column's inferred type.

Does it support SQL Server or Oracle? Not currently — this tool targets MySQL, PostgreSQL, and SQLite, which cover the vast majority of self-hosted and embedded use cases.

Is my data uploaded anywhere? No. Parsing and SQL generation run entirely in your browser — your CSV data never leaves your device.

csvsqldatabaseconverterinsertcreate table

Love the tools? Lose the ads.

One payment clears every ad from your account, for good. No subscription, no tracking.