About the CSV to SQL Converter
This tool converts a CSV file or pasted CSV text into SQL statements you can paste into a database. You pick the table name and target database dialect: MySQL or MariaDB, PostgreSQL, SQL Server, or SQLite. The converter runs entirely in your browser so nothing is uploaded to our servers. It detects the delimiter from the first row and follows RFC 4180 quoting rules. The tool guesses column types from your values and shows the inferred CREATE TABLE plus INSERT statements. Results update instantly as you type, and large files are split into 1,000-row INSERT groups. You can copy the SQL or share a link that reopens with your data. This is handy for small imports, testing, or sharing an import-ready SQL script without using a server-side uploader.
How to use it
- 1Paste your CSV or upload a file. The first row must contain column names.
- 2Enter the table name and pick MySQL/MariaDB, PostgreSQL, SQL Server, or SQLite.
- 3Choose whether to include a CREATE TABLE and the INSERT style.
- 4Copy the SQL or share the link that reopens the same data.
Worked example
Input CSV (paste exactly including quotes): id,name,amount,join_date 1,"Alice",100.5,2024-01-02 2,"Bob",200,2024-02-15 If you choose table name my_table and MySQL with one INSERT for many rows, the output is: CREATE TABLE `my_table` (`id` INT, `name` TEXT, `amount` DECIMAL(6,2), `join_date` DATE); INSERT INTO `my_table` (`id`,`name`,`amount`,`join_date`) VALUES (1,'Alice',100.50,'2024-01-02'),(2,'Bob',200.00,'2024-02-15');
How it works
The separator (comma, semicolon, tab or pipe) is detected from the first row and quoted fields follow RFC 4180Each column type is guessed from its values: whole numbers become INT (BIGINT past 2,147,483,647), decimals DECIMAL with enough digits, true/false BOOLEAN (BIT in SQL Server), YYYY-MM-DD DATE, date and time DATETIME, everything else textEmpty cells become NULL, quotes inside text are doubled, and names are quoted the way the chosen database expectsLarge files are split into INSERTs of 1,000 rowsCaveat shown on the page: Check the column types before running the SQL on a real database, and add a PRIMARY KEY if the table needs oneNumbers with leading zeros (phone numbers, IDs like 007) are kept as text on purposeResults update instantly as the visitor types; there is no calculate buttonVisitors can copy the result and share a link that reopens with their numbersSource: RFC 4180 CSV specificationPostgreSQL COPY documentationMySQL LOAD DATA documentation. Last checked 7 November 2026.
What it is good for
- Runs in your browser so your CSV does not get uploaded to our servers.
- Generates dialect-aware CREATE TABLE and batched INSERT statements.
- Splits large exports into 1,000-row INSERTs for easier imports.
- Check and correct column types before running SQL on a real database.
- For very large imports prefer the DB native bulk loader like COPY or LOAD DATA.
Questions people ask
Does the tool upload my CSV to a server?
No. The conversion runs in your browser and nothing is uploaded. If you use the share link, the data is encoded in the link you choose to copy or share.
How does the tool detect the CSV delimiter?
It checks the first row and chooses comma, semicolon, tab or pipe. Quoted fields follow RFC 4180 so commas inside quotes do not split fields.
How are column types guessed?
Whole numbers become INT, very large integers become BIGINT, decimals become DECIMAL sized to fit, booleans become BOOLEAN (or BIT for SQL Server), dates YYYY-MM-DD become DATE, and datetimes become DATETIME. Everything else becomes text.
What about numbers with leading zeros?
Numbers with leading zeros are kept as text on purpose. That preserves phone numbers and codes like 007 instead of removing the leading zero.
Can I use the SQL on a production database for large files?
For large files you should use the database bulk loader such as PostgreSQL COPY or MySQL LOAD DATA for speed. The generated INSERTs suit small to medium imports or one-off jobs.
Will the tool handle semicolon or tab delimited files?
Yes. The separator is detected automatically as comma, semicolon, tab, or pipe based on the first row. Make sure fields follow RFC 4180 quoting rules.
Help keep every tool free
FreeToolr stays free because people help it grow. Share a tool you like, tell us what to build next, or support us on Ko-fi.