Choose the JSON shape through input rules
Existing compatibility starts immediately and creates one object per data row. The first record supplies keys; blank or duplicate headers get stable unique names, and trailing all-empty records are omitted.
[{"id":"00123","value":"NULL"}]To keep raw headers, open Input rules and select Plain TSV or Spreadsheet-quoted TSV before choosing your files. Explicit rules produce an object with columns and row arrays, preserving blank or duplicate headers and correctly shaped empty records. Every record must match the header width.
{"columns":["id","id"],"rows":[["00123","NULL"],["",""]]}No type guessing in output
Cell values remain strings in both shapes, preserving leading zeroes, large identifiers and null-like text. Explicit rules show a bounded input preview: check the rules, then choose Use these rules to convert the complete files, or Keep inputs for later to change the rules and review again. Each conversion downloads a separate JSON file and leaves the original TSV unchanged.
Work with TSV using code
For repeat jobs, use Python or SQL on your computer. Choose an example below for setup, code and output details.
Convert TSV to JSON with Python
Python writes output.json as columns plus row arrays, retaining blank or duplicate headers. DuckDB writes an array of objects, which requires useful unique column names.
View code and setup
Before you start
- Install Python 3; csv and json are included, so no package installation is needed.
- Put input.tsv in your working folder. These examples read UTF-8 spreadsheet-quoted TSV with a header. For merge, add second.tsv; for editing, use columns named id and note.
- Save the Python code as tsv_task.py, then run python3 tsv_task.py from that folder. On Windows, use py tsv_task.py.
- Inspect the separate output before replacing any source file.
Python TSV task
import csv
with open("input.tsv", encoding="utf-8-sig", newline="") as source:
reader = csv.reader(source, delimiter="\t", strict=True)
columns = next(reader)
rows = list(reader)
if any(len(row) != len(columns) for row in rows):
raise ValueError("Each record must have the header's field count")
import json
with open("output.json", "w", encoding="utf-8") as result:
json.dump({"columns": columns, "rows": rows}, result,
ensure_ascii=False, indent=2)
Limits and output
- Values remain strings, including leading zeroes, empty fields and text such as NULL. This does not infer numeric or date types.
- Quoted tabs and newlines are supported. For plain TSV where quotes are literal, add quoting=csv.QUOTE_NONE to the reader; plain output cannot represent tabs or newlines inside fields without an agreed escaping rule.
- The example holds records in memory and rewrites quoting and line endings; it is not a byte-preserving copy. It does not prefix spreadsheet formulas: import sensitive columns as text and review formula-looking values before opening a spreadsheet.
Documentation: Python csv reader, writer and dialects
Convert TSV to JSON with DuckDB
Python writes output.json as columns plus row arrays, retaining blank or duplicate headers. DuckDB writes an array of objects, which requires useful unique column names.
View code and setup
Before you start
- Install the DuckDB command-line client using its official installation instructions. On macOS with Homebrew, run brew install duckdb.
- These SQL examples assume input.tsv has exactly the columns id and note. Adjust force_not_null and the editing expressions for your actual columns; add second.tsv for merging.
- Run duckdb in the folder containing the files, paste this SQL, then enter .quit when finished.
DuckDB SQL
COPY (SELECT * FROM read_csv('input.tsv', delim='\t', header=true, all_varchar=true, force_not_null=['id','note']))
TO 'output.json' (FORMAT JSON, ARRAY true);
Limits and output
- all_varchar keeps columns as text; force_not_null keeps empty id and note fields as empty strings rather than SQL NULL. DuckDB may normalize blank or duplicate column names, so use Python's columns/rows JSON shape when exact headers matter.
- This reads spreadsheet-quoted TSV, not ClickHouse-style backslash-escaped TSV. SQL exports retain literal formula-looking strings; spreadsheet applications may interpret them when opened.
- File size and operation complexity still depend on available memory and disk space; no universal large-file guarantee applies.
Documentation: DuckDB installation; DuckDB CSV options; DuckDB COPY exports
Convert TSV to JSON with ClickHouse
Create a separate output using ClickHouse locally. These SQL copies are sorted by id and note, rather than preserving physical source order.
View code and setup
Before you start
- Install the ClickHouse binary for your platform using the official installation instructions. The command below is for a Unix-style shell.
- Use a UTF-8 input.tsv with exactly the unique header names id and note. Add second.tsv with the same columns for merging; adjust the declared String schema for other files.
- Run the command from the folder containing your TSV. Choose an output name that does not already exist; ClickHouse refuses to overwrite an existing output file.
ClickHouse local command
clickhouse local --path ./tsv-local-work --max_threads 2 --multiquery <<'SQL'
SET format_csv_delimiter = '\t';
SET input_format_csv_allow_whitespace_or_tab_as_delimiter = 1;
SELECT * FROM file('input.tsv', 'CSVWithNames', 'id String, note String') ORDER BY id, note
INTO OUTFILE 'output.json' FORMAT JSONEachRow
SETTINGS output_format_json_array_of_rows = 1;
SQL
Limits and output
- The CSVWithNames reader is explicitly configured with a tab delimiter and quoted-field support. ClickHouse's native TabSeparated format instead uses backslash escaping and is not interchangeable with spreadsheet-quoted TSV.
- The declared String columns preserve leading zeroes and empty text for this schema. ClickHouse CSV rules can trim unquoted spaces; inspect whitespace-sensitive data. This is not a byte-preserving export and does not prefix formula-looking text for spreadsheet use.
- JSON output is an array of objects with unique id/note keys, not the website's raw columns/rows shape.
Documentation: ClickHouse installation; ClickHouse local; ClickHouse CSVWithNames