CSV to SQL and SQL to CSV

Convert comma-separated CSV into SQL table and insert statements in your browser. Choose SQLite, PostgreSQL or MySQL, or read a supported set of literal SQL inserts back into CSV. The converter handles text locally and never executes your SQL.

Processed on your device. No file upload.

How to use this tool

  1. Choose the conversion direction and SQL dialect, then paste comma CSV with a header or supported SQL text. CSV input also needs a destination table name.
  2. Keep text columns to preserve spelling, or select conservative integer detection. Decide whether an empty CSV cell stays empty text or becomes SQL NULL.
  3. Run conversion, check the row preview and save the SQL or CSV with its JSON report. Test generated statements separately before using them with your own database.

Check the built-in example

The contacts example has two rows and three columns: id, postal and name. Integer detection assigns INTEGER to id for SQLite, while postal remains TEXT because 00123 and 01000 have leading zeros. The name O'Reilly becomes a correctly quoted SQL string rather than a new statement. The second name is Alex Example. Converting the generated inserts back into CSV preserves all six data cells, including both postal codes and the apostrophe. The report records two rows, three columns and zero NULL values.

The two-row contacts CSV keeps postal code 00123 as text, generates SQL inserts and returns six unchanged data cells when converted back.
Actual defaults and results from “Try an example”.

Processing method

The CSV reader follows comma delimiters, double-quoted cells, doubled quotes and quoted line breaks. Every row must match the header width. SQL generation quotes identifiers and values separately for the chosen dialect. PostgreSQL uses explicit escape strings; MySQL encodes text as UTF-8 hexadecimal converted to utf8mb4, avoiding assumptions about backslash mode. Optional integer detection uses exact signed 64-bit bounds rather than JavaScript floating-point numbers. The reverse path tokenizes a deliberately small SQL grammar without starting a database or running expressions.

Reference: SQLite: SQL literal values and string quoting

What the result leaves out

Each input and output is limited to 5 MB. Maximums are 10000 rows, 100 columns, 20000 data cells, 10000 characters per cell and 63 UTF-8 bytes per identifier. SQL parsing allows up to 250000 tokens. Supported SQL contains one simple CREATE TABLE declaration and literal INSERT statements with explicit column lists for one table; CREATE may be omitted. General dumps, constraints, queries, arbitrary functions and binary columns are unsupported. Reverse numeric values retain literal spelling, including decimal or exponent notation. SQL NULL becomes an empty CSV cell, so CSV alone cannot distinguish it from empty text. Automatic type detection guesses only canonical integers; dates and decimals remain text. MySQL identifiers reject supplementary characters and trailing spaces; quoted names use backticks.

Checking local processing

Pasted tables and generated downloads remain in this browser during conversion. There is no upload, database connection or public result URL. The JSON report contains column names, counts and settings rather than cell values. Preview tables show at most 30 rows, eight columns and 500 characters per cell; downloads retain the complete supported data.

Common questions

Will postal codes lose leading zeros?

Text is the default. Even with integer detection, a value such as 00123 keeps its entire column as text.

Can I paste a complete database dump?

Only the documented simple CREATE and literal INSERT subset is supported. Other statements or unsupported expressions produce an error.

Does the converter run SQL?

No. It generates text or parses supported inserts. It does not connect to a database or execute the pasted statements.