CSV to SQL converter
To convert CSV to SQL, paste the CSV data below: the tool generates CREATE TABLE and INSERT statements for MySQL, PostgreSQL, SQLite or SQL Server – with detected column types and properly escaped text. Everything in your browser.
Source: IETF – RFC 4180: Common Format and MIME Type for CSV Files. Updated: .
How it is calculated
Converting CSV to SQL means turning a table in text form into a table in the database: first the structure (CREATE TABLE), then the rows (INSERT). The tool reads your CSV data in your browser following RFC 4180, derives the column types from all values and writes the SQL in your database’s dialect.
How it works
- Paste CSV, for example from Excel or an export (separator and decimal mark are detected).
- Choose the database and table name; if you like, clean up names, leave out CREATE TABLE or bundle INSERTs.
- Copy the SQL and run it in your database tool.
What the tool detects and adjusts
- Types: integers (INT or BIGINT), decimal numbers, booleans, dates and dates with time (also from DD.MM.YYYY), otherwise text with a fitting length. Numbers with a leading zero, such as postcodes, stay text.
- Names: in backticks, double quotes or square brackets depending on the database; optionally lower case and without special characters, duplicates are numbered.
- Text: single quotes are doubled; MySQL also escapes the backslash, SQL Server adds the N prefix for special characters.
- Empty fields: NULL or empty text, as you choose.
Limits
The generated SQL is meant for small to medium amounts of data. For very large files, COPY (PostgreSQL), LOAD DATA (MySQL), .import (SQLite) or BULK INSERT (SQL Server) are faster.
- Up to 100,000 rows and 3 million characters. Only SQL text is generated, nothing is executed; check types and names before loading.
- Primary keys, indexes and numbers with thousands separators (“1,234.50”) are not derived – such columns stay text.
Privacy
The data never leaves your browser. Next steps: CSV to JSON, CSV to Excel or format SQL.
Frequently asked questions
How do I convert CSV to SQL?
Paste the CSV and choose the database and table name: the tool generates CREATE TABLE and INSERT statements that you copy and run.
Which databases are supported?
MySQL/MariaDB, PostgreSQL, SQLite and SQL Server. Types, name quoting and escaping follow the chosen system.
How does the tool detect column types?
From all values of a column: only whole numbers give INT/BIGINT, decimals give decimal numbers, true/false a boolean, valid dates DATE. Everything else becomes text.
Why are postcodes text?
Because leading zeros (for example 01067) would be lost as a number. Numbers with a leading zero therefore stay text.
Can I convert CSV to SQL without uploading the file?
Yes. Everything runs in your browser.
How do I load very large CSV files into a database?
Use the database’s import commands (COPY, LOAD DATA, .import, BULK INSERT). This tool is meant for small to medium amounts of data and for creating the table structure.
Sources and legal basis
- IETF – RFC 4180: Common Format and MIME Type for CSV Files
- PostgreSQL – CREATE TABLE and data types
- MySQL – String Literals (escaping of ' and \)
- SQLite – Datatypes In SQLite
- Microsoft – Data types (Transact-SQL)
As of: · Editorial policy
Related tools
- CSV to JSON converter (and JSON to CSV)Convert CSV to JSON or JSON to CSV online: delimiter auto-detected, numbers and booleans typed, quoted fields handled. Runs in your browser, nothing uploaded.
- CSV to Excel ConverterConvert CSV to Excel (XLSX) without losing leading zeros in ZIP codes – and Excel back to CSV. Columns, numbers and dates come out right. Free, no upload.
- SQL formatter (format SQL online)SQL formatter for readable queries: uppercase keywords, indentation, columns and conditions on separate lines. Also minifies SQL. Runs locally in your browser.
- JSON formatter, validator and minifierValidate JSON against RFC 8259 with the exact line, column and a plain-English explanation. Beautify or minify, sort keys, copy. Runs locally in your browser.
- XML and CSV validator onlineCheck XML for well-formedness and validate CSV against RFC 4180: errors with line and column, auto-detected delimiter, table preview. Runs locally.
- JSON to TypeScript converterConvert JSON to TypeScript: generate types, interfaces or JSON Schema from sample data, with optional fields. Runs in your browser, no upload.
- What is my IP address?What is my IP? See your public IPv4 or IPv6 address at once, plus approximate location, internet provider and browser details. Free, never stored.
- Chmod CalculatorChmod calculator: tick the permissions or type 755, rwxr-xr-x or u=rwx and see every notation at once, plus the command to copy. Free, runs in your browser.
- Markdown table generatorMarkdown table generator: paste data from Excel, Google Sheets or CSV and copy it as an aligned Markdown, HTML or LaTeX table – locally in your browser.