2.0.0 • Published 4 years ago

tsv-json v2.0.0

Weekly downloads
28
License
MIT
Repository
github
Last release
4 years ago

tsv-json Build Status install size

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

License

MIT © Pedro Augusto de Paula Barbosa