Home · Free tools · CSV to SQL

CSV to SQL

Drop a .csv, name the table, pick the database. You get a CREATE TABLE whose column types come from the data — integers, decimals, dates, booleans, text sized to the longest value — and INSERT statements in batches you can paste into a console or save as a file. The delimiter and the text encoding are detected, so a semicolon-separated Shift-JIS export works without settings. Nothing is uploaded.

Your CSV

Drop .csv, .tsv or .xlsx here, or click to choose

Nothing is uploaded. The file is read by JavaScript in this tab and never leaves your computer — no server sees it, and closing the tab throws it away.

Why the built-in CSV import so often is not the answer

LOAD DATA INFILE, COPY and the import wizards all need the table to exist first, with the right column types. Working out those types by eye from a 40-column export is the part that takes the time, and getting one wrong means the load fails halfway or, worse, succeeds with everything as VARCHAR(255).

This page writes the CREATE TABLE for you and shows what each column became before you run anything.

What the type inference decides

  • Reference numbers stay text. A column of values with leading zeros is an identifier, not a quantity — it is typed as text so 00012345 survives the import.
  • Amounts lose their thousands separators. 8,600.00 becomes 8600.00 in a DECIMAL column rather than a quoted string.
  • Booleans follow the dialect. TRUE/FALSE for MySQL, PostgreSQL and SQLite; 1/0 for SQL Server's BIT.
  • Text is sized to the longest value in the column, rounded up, instead of the usual VARCHAR(255) everywhere.

Quoting and identifiers

Column names are cleaned into valid identifiers — spaces become underscores, a name starting with a digit gets a prefix, and two columns with the same name become amount and amount_2 rather than colliding. Identifiers are quoted the way the dialect wants: backticks for MySQL, double quotes for PostgreSQL and SQLite, square brackets for SQL Server. Single quotes inside values are doubled, and SQL Server strings get the N prefix so non-ASCII text survives.

Batched INSERTs

One INSERT per row is slow and one giant INSERT hits the server's packet or parameter limit. The rows are grouped — 500 by default, and capped at what the dialect allows — so a large file arrives as a manageable number of statements.

Questions people ask

Which databases does the output work with?

MySQL and MariaDB, PostgreSQL, SQLite and SQL Server. The dialect changes identifier quoting, boolean literals, the text and timestamp types, and the maximum rows in one INSERT.

Can I get only the INSERTs, without the CREATE TABLE?

Yes — uncheck Include CREATE TABLE. Useful when the table already exists and you only need to load rows into it.

My CSV uses semicolons. Do I have to convert it first?

No. Comma, semicolon, tab and pipe are detected from the first few lines, so a European export loads as-is. The text encoding is detected too — UTF-8, Shift-JIS, Big5, GBK, EUC-KR and Windows-1252 — so accented and CJK values do not arrive as mojibake.

Are my files uploaded anywhere?

No. The file is read by JavaScript running in this tab, using the browser's own DecompressionStream to unzip .xlsx and a parser that runs on your machine. There is no server call in the page — you can watch the network tab while you use it. Close the tab and the data is gone.

Why is a numeric-looking column typed as text?

Because at least one value in it has a leading zero or is longer than an exact integer. Those are identifiers; typing them as numbers would silently change them. Strip the leading zeros in the source if the column really is a quantity.

How large a file can it handle?

The ceiling is your browser tab's memory. The preview shows the first 20,000 characters of SQL and the download has all of it; for files in the hundreds of megabytes, your database's own bulk loader is the right tool, and this page is a good way to write the CREATE TABLE it needs.

Doing this every month?

TableDI 2 keeps it as a job — the files, the key columns, the tolerance and the fixes you made. Next month you drop in the new files and run it again.

macOS, Apple silicon and Intel; Windows is in progress. Free is not a trial — no account, no card.

Last reviewed 2026-09-15 by the TableDI team. Something wrong on this page? Tell us — it is one inbox, read by the people who build TableDI.