CSV to SQL Converter

Paste CSV with a header row and choose your database. The tool infers integer, decimal, boolean and date columns, quotes table and column names, escapes single quotes, and writes INSERT statements in the batch size you choose. Review the SQL before running it on a real database.

CSV to SQL Converter runs entirely in your browser: the text you paste is never sent to a server. It is free and needs no sign-up.

How to use it

  1. Paste CSV and choose a dialect Paste CSV into the Input box, then pick the SQL dialect: MySQL, PostgreSQL, SQLite or SQL Server. Name the table, and keep The first row is a header ticked when the first line holds column names.
  2. Set types, NULL and batching Guess column types from the values turns on type detection; with it off, every column is text. Write empty cells as NULL and Rows per INSERT decide how many rows each statement holds.
  3. Review the SQL before running it Read the detected columns and the SQL, then press Copy. Check the types first, because the tool does not connect to a database and does not test the statements for you.

Questions

How are column types guessed?

Whole numbers become INTEGER, decimals become a decimal type, and true or false values become BOOLEAN. Dates are detected only in the YYYY-MM-DD form. A code with a leading zero, such as a postal code, stays text so the zero is not lost. Everything else is text.

Which dialect differences should I check?

MySQL quotes names with backticks, PostgreSQL and SQLite use double quotes, and SQL Server uses square brackets. Booleans are written as TRUE and FALSE in MySQL and PostgreSQL, but as bit values in SQLite and SQL Server. SQL Server text also gets an N prefix.

Can I run the generated SQL as it is?

Not without review. The tool does not connect to a database, so the statements are only text. Check the column types and the table name, and see whether a table with that name already exists, because CREATE TABLE fails in that case. Try it on a copy first.