CSV to SQL Converter

Paste CSV, TSV, or a spreadsheet selection and get INSERT statements or a CREATE TABLE script with inferred column types — for SQL Server, PostgreSQL, MySQL, Oracle, or SQLite. Everything runs in your browser; nothing is uploaded.

Generated SQL

How type inference works

When you generate a CREATE TABLE script, the converter scans every value in every column — not just the first row — and picks the narrowest type that fits all of them:

  • All-integer columns become INT, promoted to BIGINT when any value exceeds the 32-bit range (±2,147,483,647).
  • Decimal columns become DECIMAL(p,s) with precision and scale sized from the widest value actually present in the data.
  • ISO dates (YYYY-MM-DD) become DATE; ISO datetimes map to the engine's native type (DATETIME2, TIMESTAMP, DATETIME).
  • true/false columns map to the engine's boolean equivalent.
  • Everything else becomes a text type sized to the next bucket above the longest value (50 / 100 / 255 / 1000, then MAX/TEXT/CLOB).
  • Values with leading zeros — zip codes, phone extensions, product codes like 007 — stay text, because casting them to integers would silently destroy the zeros.
  • Empty fields are ignored when picking a type, but any column containing one is left nullable; only columns with no empties get NOT NULL.

Know the limits: the inference sees only the sample you paste, not your real schema. Fifty rows of integers don't prove the production feed will never send an alphanumeric code, a column that happens to contain numbers may still be semantically text (phone numbers, account codes), and no primary keys, foreign keys, or indexes are guessed. Treat the generated DDL as a solid first draft to review — not a finished schema.

Engine differences that matter when bulk-inserting

  • SQL Server — a single INSERT … VALUES statement is hard-capped at 1,000 row value expressions (error 10738), so the converter batches at 500 rows per statement. Text columns are generated as NVARCHAR rather than VARCHAR: CSV is Unicode in practice, and one stray accented name in a VARCHAR column becomes ? on insert.
  • Oracle — classic Oracle simply doesn't support multi-row VALUES lists (that finally arrived in Database 23ai), so the output is one INSERT per row; the traditional single-statement workaround is INSERT ALL … SELECT 1 FROM DUAL. Dates are emitted as DATE '2024-03-01' and TIMESTAMP '…' literals so the script doesn't break on a session's NLS_DATE_FORMAT, and long text falls back to CLOB because VARCHAR2 tops out at 4,000 bytes by default.
  • Identifier quoting — SQL Server uses [brackets], MySQL uses `backticks`, and PostgreSQL, Oracle, and SQLite use "double quotes". The converter only quotes when a name needs it (spaces, special characters, reserved words) — in PostgreSQL and Oracle, quoting also makes the name case-sensitive forever, so lowercase headers like first name are folded to first_name and left unquoted instead.
  • MySQL — multi-row VALUES has no row cap, but very large statements can exceed max_allowed_packet; 500-row batches keep each statement comfortably small.
  • SQLite — multi-row VALUES works (since 3.7.11), but there are no VARCHAR(n) semantics, so text, dates, and datetimes all become TEXT — the idiomatic way to store ISO-8601 values in SQLite.
This tool is for ad-hoc loads, test fixtures, and seed scripts. For recurring or multi-megabyte imports, use the engine's bulk loader — BULK INSERT/bcp, COPY, LOAD DATA INFILE, SQL*Loader, or .import — which is orders of magnitude faster than INSERT statements.

Frequently asked questions

How do I convert a CSV file to SQL INSERT statements?

Open the CSV in any text editor (or copy cells straight from Excel or Google Sheets), paste it into the converter above, set the table name and target engine, and copy the generated INSERT statements. The first row is treated as column headers by default, and the delimiter — comma, tab, or semicolon — is detected automatically. Everything runs locally in your browser.

How many rows can I convert?

The converter generates SQL for up to 5,000 rows. If you paste more, it emits the first 5,000 and shows a warning instead of silently truncating. For bigger loads use a bulk import tool — BULK INSERT or bcp for SQL Server, COPY for PostgreSQL, LOAD DATA INFILE for MySQL, SQL*Loader for Oracle, or .import in the SQLite CLI.

How are data types chosen for CREATE TABLE?

Every value in every column is scanned. All-integer columns become INT (BIGINT when any value exceeds the 32-bit range), decimals become DECIMAL(p,s) sized from the widest value, ISO dates (YYYY-MM-DD) become DATE, ISO datetimes map to each engine's datetime type, and true/false columns map to the engine's boolean equivalent. Everything else becomes a text type sized to the next bucket above the longest value (50/100/255/1000, then MAX). Values with leading zeros, like zip codes, stay text. Columns with no empty values are marked NOT NULL.

How are empty CSV fields handled?

By default empty fields become NULL. Uncheck 'Empty fields as NULL' to insert empty strings ('') into text columns instead — empty values in numeric, date, and boolean columns are always NULL, because an empty string is not valid there. Any column containing an empty field is left nullable in the generated CREATE TABLE.

Why does SQL Server limit multi-row inserts to 1000 rows?

SQL Server rejects an INSERT ... VALUES statement with more than 1,000 row value expressions (error 10738) — it is a hard parser limit, not a configuration setting. The converter batches SQL Server output at 500 rows per INSERT, which stays well under the cap and keeps each statement a manageable size for the query editor.

Is my data uploaded?

No. The converter is plain JavaScript running entirely in your browser — the page makes no network requests with your data, and nothing you paste leaves your machine. You can disconnect from the internet after the page loads and it keeps working.

Loading CSVs into a real database?

Jam SQL Studio is a free desktop SQL client for SQL Server, PostgreSQL, MySQL, Oracle, and SQLite — browse and edit table data in a spreadsheet-like grid, run bulk loads, and export results in any format.

Free for personal use • No account required • Mac, Windows, Linux

More free SQL tools