Convert TSV to SQL Online
Convert TSV files to SQL INSERT statements directly in your browser. Copy or download the generated SQL — no upload required.
About converting TSV to SQL
Turning a TSV into SQL is useful when the data has to land in a database you can only reach through a query window or a migration file. Examples include loading a reference table (gene annotations, sample metadata, code lists) into PostgreSQL or SQLite for a web app, committing a reproducible fixture to a repository, or moving rows from a tab-delimited export into a database that cannot read the file.
The script has one CREATE TABLE IF NOT EXISTS statement with inferred column types, then one INSERT per TSV line for the first 1,000 lines. Text is single-quoted with apostrophes doubled. That matters for scientific names and descriptions, which are full of primes and possessives: 5'-nucleotidase, Crohn's disease.
TSV-specific trouble comes from dump conventions. PostgreSQL's COPY text format and MySQL's INTO OUTFILE write \N for NULL and escape tabs and newlines with backslashes. This converter does not interpret those escapes, so \N becomes the string '\N' rather than NULL, and a numeric column that contains it is declared TEXT. For those dumps, reloading with the database's own COPY or LOAD DATA is more faithful. Use this converter for TSVs written by people, spreadsheets and analysis tools.
Worked example
A small sample file, converted with the default settings.
Input (TSV)
symbol chrom description tpm detected
TP53 chr17 tumor protein p53 24.7 true
BRCA1 chr17 BRCA1 DNA repair associated 8.13 true
NT5C chr17 5', 3'-nucleotidase, cytosolic 3.4 true
SREBF2 chr22 sterol regulatory element binding transcription factor 2 falseOutput (SQL)
CREATE TABLE IF NOT EXISTS "data" (
"symbol" TEXT,
"chrom" TEXT,
"description" TEXT,
"tpm" DOUBLE PRECISION,
"detected" BOOLEAN
);
INSERT INTO "data" VALUES ('TP53', 'chr17', 'tumor protein p53', 24.7, true);
INSERT INTO "data" VALUES ('BRCA1', 'chr17', 'BRCA1 DNA repair associated', 8.13, true);
INSERT INTO "data" VALUES ('NT5C', 'chr17', '5'', 3''-nucleotidase, cytosolic', 3.4, true);
INSERT INTO "data" VALUES ('SREBF2', 'chr22', 'sterol regulatory element binding transcription factor 2', NULL, false);What changes when you convert TSV to SQL
- The CREATE TABLE declares symbol, chrom and description as TEXT, tpm as DOUBLE PRECISION and detected as BOOLEAN.
- Each TSV line after the header becomes one INSERT INTO statement.
- NT5C's description is written as '5'', 3''-nucleotidase, cytosolic', with each apostrophe doubled.
- SREBF2's missing tpm is written as NULL.
- The example table is named data. The tool uses your file name, so genes.tsv produces a table called genes.
Your file is processed locally in your browser and is never uploaded. The free limit is 50 MB per file; larger files work if your device has the memory for them.
Frequently Asked Questions
Why is \N in my TSV not becoming NULL?
Only empty fields are treated as missing. The \N marker used by PostgreSQL and MySQL dumps is read as a two-character string. Replace \N with an empty field before converting, or load the dump with COPY or LOAD DATA, which understand it.
Will the script run in SQLite?
Yes. SQLite accepts the double-quoted names, CREATE TABLE IF NOT EXISTS, and true/false literals (from version 3.23). It stores BOOLEAN columns as the integers 1 and 0.
How do I make the INSERT statements load faster?
Wrap them in a single transaction by adding BEGIN; before the first INSERT and COMMIT; after the last. Without it, PostgreSQL and SQLite commit after every row, which is much slower once you have more than a few hundred rows.
What is SQL format?
SQL (Structured Query Language) is the standard language for querying and manipulating relational databases. The output contains CREATE TABLE and INSERT INTO statements ready to run against any SQL-compatible database.
Related Tools
TSV Viewer Online
View and inspect TSV files directly in your browser. Browse rows, check column names and data types — no upload required, your data stays on your device.
Convert TSV to CSV Online
Convert TSV files to CSV format directly in your browser. No upload required — your data never leaves your device.
Convert TSV to Parquet Online
Convert TSV files to Parquet format directly in your browser. No upload required — your data never leaves your device.
Convert TSV to Excel Online
Convert TSV files to Excel format directly in your browser. No upload required — your data never leaves your device.
Convert TSV to JSON Online
Convert TSV files to JSON format directly in your browser. No upload required — your data never leaves your device.