CSV to SQL Converter – Free, Online, Private
Turn a CSV table into an INSERT statement. The header row supplies column names and each following row is a value tuple.
How to convert CSV to SQL
- Paste CSV with a header row.
- Set the table name. The default is records.
- Copy the INSERT and review types before you run it.
From cells to literals
The header becomes the column list. Each data row becomes a parenthesized tuple in one INSERT. Cells that dynamic typing reads as numbers or booleans are unquoted literals. Other cells are single-quoted strings with quotes doubled. An empty cell is NULL rather than an empty string, which is what you usually want for a missing measurement and the wrong choice for a missing label. If an empty name should stay '', edit that literal after copying. Rows with fewer cells than the header are padded with NULL.
Typing surprises
A zip code of 01234 typed without quotes becomes the number 1234 and the zero is gone before SQL sees it. Quote that column in the CSV or cast it after import. Dates stay strings unless they are bare numbers. The European semicolon separator is not the default. Headers are used as identifiers and are double-quoted when they are not plain names, so a header like order is quoted rather than treated as the keyword. There is still no CREATE TABLE. Match the statement to a table you already migrated.
Worked example
The sample people file produces columns id, name, active, city and two tuples. id values are numbers, active is TRUE, cities are strings. Set the table to people if that is the destination. The statement ends with a semicolon so it can sit in a script next to other inserts. Very large pastes are limited by the tab's memory, not by an upload cap, because nothing is uploaded. For JSON arrays, the JSON to SQL page emits the same kind of statement.
Review before you run
Generated SQL is only as good as the sheet. A formula someone left in a cell, a totals row, or a repeated header in the middle will become data. Delete those rows first. The page does not wrap the statement in a transaction. Add BEGIN and COMMIT in your client if the import should be atomic. Do not point this at a production table until you have read the tuples. The convenience is the quoting, not a judgment that the rows are correct.
Frequently asked questions
Does the header become columns?
Yes. The first CSV record is the column list. It is not inserted as a data row.
What is an empty cell?
NULL. Change it to '' in the output if the column is NOT NULL and an empty string is the real value.
Can I name the table?
Yes. The table box defaults to records and quotes unusual names.
Is the CSV uploaded?
No. Parsing and SQL rendering stay in the browser.