SQL & Data

CSV to SQL Converter

Paste a CSV or open a file and get a ready-to-run CREATE TABLE and INSERT script for MySQL, PostgreSQL, SQL Server or SQLite. Column types are detected for you, Indian number formats and DD/MM/YYYY dates are handled, and the file never leaves your browser.

Your CSV

The first row can hold column names. Quoted values may contain commas, line breaks and doubled quotes (""). Empty cells become NULL. You can also drop a .csv file on the box.

Parsing options
Paste a CSV and press Convert, or load the example.

What this converter does

It turns a spreadsheet export into a SQL script you can run straight away: a CREATE TABLE statement with a sensible type for every column, followed by INSERT statements that load every row. It is the quickest way to get a CSV from a client, a Kaggle dataset or an Excel sheet into MySQL, PostgreSQL, SQL Server or SQLite so you can start writing queries.

The parser follows RFC 4180, the closest thing CSV has to a standard: values in double quotes may contain the delimiter, line breaks and quotes written twice (""). The delimiter (comma, tab, semicolon or pipe) and the header row are detected, and you can override both.

How the column types are chosen

Every non-empty value in a column is checked, not just the first few rows. The first rule that fits all of them wins.

Values in the columnTypeExample
true / false, yes / no, t / f, y / nBOOLEANyes
Whole numbers up to 2,147,483,647INT1001
Larger whole numbersBIGINT9876543210123
Numbers with decimalsDECIMAL(p,s)1,24,999.50
Numbers in scientific notationDOUBLE1.5e-7
DatesDATE02/10/2026
Dates with a timeDATETIME2026-10-04 18:30
Anything else, up to 4,000 charactersVARCHAR(n)Mumbai
Longer textTEXTa product review

In DECIMAL(p,s), s is the most digits after the decimal point and p is s plus the most digits before it, so 1,24,999.50 needs DECIMAL(8,2). A value with a leading zero such as a PIN code or 007 keeps the whole column as text, because a number type would drop the zero.

Worked example: UPI orders from an online store

Press Load example. The file has eight orders with the kind of mess real exports contain: amounts written the Indian way inside quotes ("1,24,999.50"), dates as DD/MM/YYYY, delivery times missing for orders still in transit, a note with a comma, a note that runs over two lines, a doubled quote, a Windows folder path with backslashes, and a review in Hindi.

  • order_id becomes INT and the primary key, because it is named like an ID and every value is unique.
  • amount_inr becomes DECIMAL(8,2), and 1,24,999.50 is written as 124999.50.
  • paid_upi (yes / no) becomes BOOLEAN: TRUE and FALSE in MySQL and PostgreSQL, 1 and 0 in SQL Server and SQLite.
  • order_date becomes DATE, with 02/10/2026 rewritten as 2026-10-02. delivered_at becomes DATETIME, with NULL for the two undelivered orders.
  • pincode stays an INT here because no PIN starts with 0, but switch it to VARCHAR in the Columns tab if you prefer codes as text.

Switch the Database menu to compare the four dialects; the Columns tab shows the exact type each one gets.

Dialect differences at a glance

MySQLPostgreSQLSQL ServerSQLite
Quoted name`city`"city"[city]"city"
BooleanBOOLEAN, TRUEBOOLEAN, TRUEBIT, 1INTEGER, 1
TextVARCHAR(n)VARCHAR(n)NVARCHAR(n), N'...'TEXT
Date and timeDATETIMETIMESTAMPDATETIME2TEXT (ISO)
Backslash in a stringDoubledAs isAs isAs is
Create only if missingIF NOT EXISTSIF NOT EXISTSIF OBJECT_ID(...) IS NULLIF NOT EXISTS

Doing the same in Python

If you already work in pandas, this is the equivalent for SQLite. It is handy for scripts, but you lose control over the column types unless you pass dtype yourself.

import pandas as pd, sqlite3

df = pd.read_csv("upi_orders.csv", thousands=",", dayfirst=True,
                 parse_dates=["order_date", "delivered_at"])
with sqlite3.connect("shop.db") as con:
    df.to_sql("upi_orders", con, if_exists="replace", index=False)
    print(con.execute("SELECT COUNT(*) FROM upi_orders").fetchone())

Common mistakes

  • Saving from Excel with long IDs. Excel shows 16 digit numbers as 1.23457E+15 and stores them rounded. Format the column as text before you export.
  • Mixing DD/MM and MM/DD. 03/04/2026 is 3 April in India and 4 March in the US. Check the Date order note before you load.
  • Unquoted commas. A value such as Gift wrap, no invoice must be in double quotes in a comma separated file, otherwise the row gains a column. The converter names the row so you can fix it.
  • Loading backslashes into MySQL by hand. MySQL reads \n inside a string as a line break, so a path like C:\new changes. The MySQL output here doubles every backslash.
  • Keeping VARCHAR(255) everywhere. Right-sized columns document the data and catch bad rows. Use the Text column size option to choose exact or rounded lengths.

Related learning on Codeayan

FAQ

CSV to SQL questions

Is my CSV uploaded anywhere?

No. The file is read by your own browser with the FileReader API and converted by JavaScript on this page. Nothing is sent to Codeayan or anyone else, so you can safely convert customer lists, payroll extracts or anything else you would not want to leave your laptop.

How does the converter choose a type for each column?

It looks at every non-empty value in the column. If all of them are true/false or yes/no it picks BOOLEAN; whole numbers give INT, or BIGINT past 2,147,483,647; numbers with decimals give DECIMAL(p,s) sized to the widest value; dates give DATE, dates with times give DATETIME; anything else is VARCHAR(n), or TEXT for values longer than 4,000 characters. You can override any choice in the Columns tab and the SQL updates instantly.

Why are my PIN codes, phone numbers or product codes kept as text?

Because a number column would silently drop the leading zero: 007 would load as 7, and a 12 digit ID could be rounded if it went through a spreadsheet. Any column where a value starts with 0, or has a + sign or spaces, stays text. That is almost always what you want for codes you never do arithmetic on.

My dates are written as DD/MM/YYYY. Will they load correctly?

Yes. Dates are rewritten in ISO form (2026-10-02), which every database reads the same way. If any value has a first part above 12 the column is read as DD/MM, if any has a second part above 12 it is read as MM/DD, and if every value is ambiguous the converter assumes DD/MM, the Indian and British order. Change Date order under Parsing options if your file uses US dates.

What changes between MySQL, PostgreSQL, SQL Server and SQLite?

Identifier quoting (backticks, double quotes or square brackets), boolean values (TRUE and FALSE, or 1 and 0 in SQL Server and SQLite), type names (NVARCHAR and DATETIME2 in SQL Server, TEXT and INTEGER in SQLite), how CREATE TABLE IF NOT EXISTS is written, and string escaping: MySQL treats a backslash as an escape character, so the converter doubles it, and SQL Server strings get the N prefix so Hindi, Tamil or emoji survive.

How big a CSV can I convert, and how do I load it?

Tens of thousands of rows convert in a second or two. Run the file with mysql db < file.sql, psql -d db -f file.sql, sqlite3 my.db < file.sql or sqlcmd -i file.sql. Keep Rows per INSERT between 100 and 1,000 (SQL Server allows at most 1,000). For millions of rows, use LOAD DATA INFILE, COPY or BULK INSERT with the CREATE TABLE statement from here.

More tools

Keep going