CSV to SQL
Convert CSV or TSV tables into SQL INSERT statements with an RFC 4180 parser, custom delimiters, an optional header row, optional CREATE TABLE and MySQL, PostgreSQL or SQLite quoting.
Runs in your browserEvery computation happens in your browser — your data never leaves this device.
Conversion settings
The parser follows RFC 4180: quoted fields, embedded newlines, doubled quotes and both CRLF and LF line endings.
Result
What this tool does
- Turn a CSV exported from Excel or Numbers, or a log table, into INSERT statements without hand-fixing quotes and commas.
- Generate a CREATE TABLE plus INSERTs from column names, values and sample data: types are inferred per column from the actual cells.
- Handle European-style files (semicolon separators, commas or newlines inside fields) thanks to delimiter auto-detection and an RFC 4180 parser.
- Produce scripts for MySQL, PostgreSQL and SQLite from the same file by switching the dialect, which changes identifier quoting and escaping.
Example
Input
id,name,note 1,Ada,"Beijing, CN" 2,Bob,Shanghai
Output
INSERT INTO `people` (`id`, `name`, `note`) VALUES (1, 'Ada', 'Beijing, CN'), (2, 'Bob', 'Shanghai');
A cell containing a comma is unquoted by the RFC 4180 parser first and then written into SQL as one complete string.
Frequently asked questions
How do I handle commas, newlines or quotes inside a field?
Wrap the whole field in double quotes as RFC 4180 prescribes: escape inner quotes by doubling them ("") and keep newlines inside the quotes. The parser turns that back into a single value and then applies SQL escaping.
Are numbers and booleans written as strings?
Type inference is on by default and lossless: only text that survives a round trip becomes a number (1 and -2.5 do, 007 and 1.50 do not), and true / false become TRUE / FALSE. Untick "Type inference" to treat every cell as text.
Do empty cells become NULL or an empty string?
NULL by default, which is usually what you want when importing data. If an empty string is meaningful in your schema, untick "Write NULL for empty cells" and they are emitted as ''.
What happens when a row has the wrong number of columns?
You get a notice with the exact line number: extra cells are dropped and missing ones are treated as empty (NULL). The conversion still completes, so you can spot and fix bad rows instead of losing the whole file.
What if the first row is data, not a header?
Untick "First row is a header": columns become column1, column2, … and the first row is imported as data. Duplicate header names are automatically suffixed with _2, _3 so the generated SQL never has duplicate columns.
Keywords:csv to sqlcsv insertsql generatorcreate tablerfc 4180mysqlpostgresqlsqliteCSV转SQL生成 INSERT表格导入分隔符