What JSON to TSV does
JSON to TSV reads JSON and writes it as TSV. The input is parsed first, so a syntax error is reported with its position instead of producing broken output.
JSON to TSV examples
The built-in sample
Input
{"name":"Ada Lovelace","active":true,"tags":["math","code"],"address":{"city":"London"}}Output
name active tags address.city
Ada Lovelace true "[""math"",""code""]" LondonThis is the input that the Load sample button fills in.
The same rows as tab-separated values
Input
[{"id":1,"user":{"name":"Ada","langs":["en","fr"]},"note":"a, b"},{"id":2,"user":{"name":"Lin"},"active":false}]Output
id user.name user.langs note active
1 Ada "[""en"",""fr""]" a, b
2 Lin falseColumns are separated by tab characters. The value "a, b" needs no quotes here, because a comma is not special in TSV, but the JSON text of the langs array is still quoted because it contains quote characters.
Each output was produced by running this tool on the input above it.
How it works
Reading JSON. The input is parsed as JSON (RFC 8259). If it is not valid, the conversion stops and the error shows the line and column of the problem.
Writing TSV. Each object becomes a tab-separated row with the same flattening as CSV: dotted column names for nested objects and JSON text for arrays. Values containing tabs, quotes or line breaks are quoted.
Details and limits
- There is no fixed size limit: everything runs on your device, so very large inputs depend on its memory.
- It works in current browsers on phones, tablets and computers, and it is free with no account needed.
- Values are carried across without losing anything in ordinary data; the points above list the cases the two formats handle differently.
- TSV has no single agreed standard for special characters. This tool quotes a value that contains a tab, a line break or a double quote, in the same way CSV does, and doubles the inner quotes. Spreadsheet applications read that correctly; a simple "split on tab" script will not.
- Tab-separated text can be pasted straight into a spreadsheet: each tab moves to the next cell.
- Flattening is the same as in JSON to CSV: dotted names for nested objects, JSON text for arrays, the union of all keys as the header.
- Input that is not valid JSON stops the tool, and the status line shows where the problem is. The JSON Validator page lists the usual causes.
Questions
When is TSV a better choice than CSV?
When the data contains many commas, as addresses and prose do, and when you want to paste the result into a spreadsheet, which splits pasted text on tabs.