How to convert CSV to SQL
- Drop your CSV file on the box above, or paste its content into the text box.
- Check the settings below the box; the defaults suit most files.
- Press Convert. You see a preview or a summary of the result.
- Download the .sql file, or copy the text.
What is kept when you convert CSV to SQL
- A CREATE TABLE statement uses the headers as column names, with INTEGER/BIGINT, exact DECIMAL(p,s) or TEXT types inferred from the data.
- Values are escaped for the chosen database (MySQL, PostgreSQL, SQLite, SQL Server); rows are grouped into multi-row INSERTs of up to 500.
- Empty cells can become NULL, and numbers are only left unquoted when every value in the column is a plain number.
Example
A short CSV input and the exact output this tool produces from it:
Input
name,city,score
"Smith, John",London,42
Anna,"New ""York""",7.5 Output
CREATE TABLE `people` (
`name` TEXT,
`city` TEXT,
`score` DECIMAL(3,1)
);
INSERT INTO `people` (`name`, `city`, `score`) VALUES
('Smith, John', 'London', 42),
('Anna', 'New "York"', 7.5);
About CSV and SQL files
CSV (comma-separated values) is a table as plain text: one row per line, fields separated by commas, and fields that contain commas, quotes or line breaks wrapped in double quotes. It opens in Excel, Google Sheets, LibreOffice, any database tool.
A .sql file is a script of statements — here a CREATE TABLE and INSERT statements — that a database runs to create and fill a table. It opens in MySQL, PostgreSQL, SQLite, SQL Server and their clients.
Good to know
- If a spreadsheet showed all your data in one column, the file probably uses semicolons (common in Europe); choose the delimiter instead of relying on detection.
- Run the script inside a transaction (BEGIN … COMMIT) on a test database first, so a mistake can be rolled back.
Privacy and limits
The file is read and converted by this page in your browser; there is no upload and no account. Files up to 25 MB are accepted; a file of the wrong type or a damaged file is rejected with the reason.