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.
Classic Oracle doesn't accept multi-row VALUES lists, so each row gets its own INSERT statement. The INSERT ALL … SELECT 1 FROM DUAL form is the traditional single-statement workaround, and Oracle Database 23ai finally supports multi-row VALUES. Date and timestamp values are emitted as DATE '…' / TIMESTAMP '…' literals so they don't depend on the session's NLS_DATE_FORMAT.
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 toBIGINTwhen 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) becomeDATE; ISO datetimes map to the engine's native type (DATETIME2,TIMESTAMP,DATETIME). true/falsecolumns 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 … VALUESstatement is hard-capped at 1,000 row value expressions (error 10738), so the converter batches at 500 rows per statement. Text columns are generated asNVARCHARrather thanVARCHAR: CSV is Unicode in practice, and one stray accented name in aVARCHARcolumn becomes?on insert. - Oracle — classic Oracle simply doesn't support multi-row
VALUESlists (that finally arrived in Database 23ai), so the output is oneINSERTper row; the traditional single-statement workaround isINSERT ALL … SELECT 1 FROM DUAL. Dates are emitted asDATE '2024-03-01'andTIMESTAMP '…'literals so the script doesn't break on a session'sNLS_DATE_FORMAT, and long text falls back toCLOBbecauseVARCHAR2tops 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 likefirst nameare folded tofirst_nameand left unquoted instead. - MySQL — multi-row
VALUEShas no row cap, but very large statements can exceedmax_allowed_packet; 500-row batches keep each statement comfortably small. - SQLite — multi-row
VALUESworks (since 3.7.11), but there are noVARCHAR(n)semantics, so text, dates, and datetimes all becomeTEXT— the idiomatic way to store ISO-8601 values in SQLite.
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
All Free SQL Tools
The full collection — formatters, converters, and generators for everyday SQL work.
SQL IN Clause Generator
Turn a pasted list into a quoted, escaped, deduplicated IN (...) list — with Oracle's 1,000-item limit handled.
SQL Formatter
Format and beautify SQL with dialect-aware rules for T-SQL, PostgreSQL, MySQL, PL/SQL, and SQLite.
SQL Data Type Converter
Map data types across SQL Server, PostgreSQL, MySQL, Oracle, and SQLite — with precision and pitfall notes.
Jam SQL Studio