Registry / serialization / tsv
library1.2jsnpmunverified

The `tsv` package provides a lightweight, dependency-free solution for converting between JSON and Tab-Separated Values (TSV) or Comma-Separated Values (CSV) formats. Currently at version 0.2.0 (published 13 years ago), this library is explicitly marked by its author as unmaintained and unsuitable for production environments due to its synchronous parsing, inefficiency with large datasets, and vulnerability to non-sanitized input data. It was originally designed for efficiently serving small datasets to client-side visualization libraries like D3.js. Given its age and the author's deprecation notice, it lacks modern features like asynchronous processing, robust error handling for malformed data, and native ESM support, common in contemporary data parsing libraries.

npm install tsv
INSTALL
IMPORT
SIG · TSV
T
tsv
serializationjavascriptv1.2
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

TSV
const TSV = require('tsv').TSV;
import { TSV } from 'tsv'; // ESM imports are not supported
This package is primarily CommonJS. The main 'tsv' module exports a top-level object containing TSV and CSV utilities. Explicit named exports are not provided for ESM.
CSV
const CSV = require('tsv').CSV;
import { CSV } from 'tsv'; // ESM imports are not supported
The CSV utility is accessed as a property of the main module export, alongside TSV. CommonJS 'require' is the intended mechanism.
Parser
const { Parser } = require('tsv'); const customParser = new Parser('|');
import { Parser } from 'tsv'; // ESM imports are not supported
For custom delimiters, the `Parser` class is available. It's best destructured from the `require('tsv')` call, similar to how it would appear in CoffeeScript as shown in the original README.

Demonstrates basic TSV and CSV stringification and parsing, including creating a custom parser for other delimiters. Shows synchronous API usage.

const { TSV, CSV, Parser } = require('tsv'); // --- TSV Operations --- const tsvData = [ { id: 1, name: 'Alice', age: 30 }, { id: 2, name: 'Bob', age: 24 }, { id: 3, name: 'Charlie', age: 35 } ]; const tsvString = TSV.stringify(tsvData); console.log('Generated TSV:\n', tsvString); /* Outputs: id\tname\tage 1\tAlice\t30 2\tBob\t24 3\tCharlie\t35 */ const parsedTsv = TSV.parse(tsvString); console.log('Parsed TSV:\n', parsedTsv); // Outputs: [ { id: '1', name: 'Alice', age: '30' }, ... ] (Note: numbers parsed as strings) // --- CSV Operations --- const csvData = [ { city: 'London', country: 'UK' }, { city: 'Paris', country: 'France' } ]; const csvString = CSV.stringify(csvData); console.log('\nGenerated CSV:\n', csvString); /* Outputs: city,country London,UK Paris,France */ const parsedCsv = CSV.parse(csvString); console.log('Parsed CSV:\n', parsedCsv); // --- Custom Separator --- const PipeSeparatedValues = new Parser('|'); const psvString = 'col1|col2\nval1|val2'; const parsedPsv = PipeSeparatedValues.parse(psvString); console.log('\nParsed PSV (custom separator):\n', parsedPsv);
tsv --version
Debug
Known issues
breakingThis package is explicitly unmaintained and deprecated by its author. It is strongly advised not to use it in production environments due to potential security vulnerabilities, lack of updates, and known limitations.
fix
Migrate to a actively maintained and robust parsing library such as `papaparse` or `csv-parse` which support modern JavaScript features, asynchronous processing, and handle complex data scenarios reliably.
affects: >=0.2.0
gotchaThe parser is synchronous, which can block the Node.js event loop and lead to performance issues when processing large datasets.
fix
For large files or server-side applications, use a streaming parser that handles data asynchronously to prevent blocking the main thread, such as `node-csv-parser`.
affects: >=0.2.0
gotchaThe parser performs 'dumb parsing' and is not suitable for uncleaned or non-sanitized input data, potentially leading to incorrect parsing results or unexpected behavior.
fix
Ensure all input data is strictly formatted according to TSV/CSV standards or utilize a more resilient parsing library that offers robust error handling and configuration for various data anomalies.
affects: >=0.2.0
gotchaThis package exclusively uses CommonJS modules (`require`). Attempting to use `import` syntax will result in errors in an ESM-only project.
fix
For ESM projects, consider using dynamic `await import()` if absolutely necessary, but preferably switch to a modern library with native ESM support. Otherwise, ensure your project is configured for CommonJS compatibility.
affects: >=0.2.0
Errors
Common errors & fixes
TypeError: TSV.stringify is not a function
Attempting to use `TSV` or `CSV` functions as part of a default export when only specific properties are available on the required module.
fix
Ensure you are accessing `TSV` or `CSV` as properties of the object returned by `require('tsv')`, e.g., `const { TSV, CSV } = require('tsv');` or `const tsvModule = require('tsv'); tsvModule.TSV.stringify(...)`.
Error: TSV: The data argument for stringify must be a flat array of objects.
The `stringify` method expects an array of plain JavaScript objects, where keys from the first object define the headers. Non-flat arrays, empty arrays, or arrays of non-objects will cause this error.
fix
Transform your data into a `[{ key1: val1, key2: val2 }, { key1: val3, key2: val4 }]` structure before calling `stringify`. Ensure the array is not empty and contains valid objects.
Upgrade
Version history
1.2latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
19 hits · last 30 days
node
18
OpenAI (training)
1
Resources
tsv — npm install tsv · libregistry