tsv-json
v2.0.0
Published
Convert between TSV and JSON (`string[][]`)
Downloads
2,007
Maintainers
Readme
tsv-json
Convert between TSV and JSON (
string[][]
)
Highlights
- Zero dependencies
- Simple and to the point
- Written in TypeScript
- Handles double-quotes correctly
Install
$ npm install tsv-json
Usage
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
).
Tip for Excel
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.
Related
- tsv-json-cli - CLI for this module