Convert between TSV and JSON (
string[][]
)
- Zero dependencies
- Simple and to the point
- Written in TypeScript
- Handles double-quotes correctly
$ npm install tsv-json
const { tsv2json, json2tsv } = require('tsv-json');
console.log(json2tsv([
['foo', 'bar'],
['baz', 'qux']
]));
//=> 'foo\tbar\nbaz\tqux'
console.log(tsv2json('foo\tbar\nbaz\tqux'));
//=> [['foo', 'bar'], ['baz', 'qux']]
Handles tabs, newlines and double-quotes correctly.
Asserts the input is of the expected type (string[][]
for json2tsv
, string
for tsv2json
).
If you copy any TSV generated by this package and paste directly on an Excel cell, Excel will automatically parse the TSV and fit everything in the appropriate rows and columns, starting at the cell highlighted by you.
- tsv-json-cli - CLI for this module