# json-text-sequence

> Parse and generate RS-delimited JSON sequences according to draft-ietf-json-text-sequence

Latest version **4.0.3** (published 2026-03-05) · MIT license · 136.9K weekly downloads

## Install

```sh
npm install json-text-sequence
pnpm add json-text-sequence
yarn add json-text-sequence
bun add json-text-sequence
```

## Health

**Score 75/100 (B)** — status: stable.

Positive: moderate downloads; has types; esm support; no vulnerabilities; has provenance.

## Facts

| | |
|---|---|
| Version | 4.0.3 |
| Published | 2026-03-05 |
| First published | 2014-09-22 |
| Weekly downloads | 136.9K |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=20 |
| Dependencies | 1 |
| Unpacked size | 7.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 17 |
| Author | Joe Hildebrand |
| Maintainers | hildjj |
| Keywords | json, sequence, stream, RS |

## Links

- npm: https://www.npmjs.com/package/json-text-sequence
- Repository: https://github.com/hildjj/json-text-sequence
- Issues: https://github.com/hildjj/json-text-sequence/issues
- npm.io page: https://npm.io/package/json-text-sequence

## Dependencies (1)

- [@sovpro/delimited-stream](https://npm.io/package/@sovpro/delimited-stream.md) ^1.1.0

## Alternatives

- [@mapbox/jsonlint-lines-primitives](https://npm.io/package/@mapbox/jsonlint-lines-primitives.md) — 5.3M weekly downloads
- [reftools](https://npm.io/package/reftools.md) — 3.5M weekly downloads
- [@hey-api/openapi-ts](https://npm.io/package/@hey-api/openapi-ts.md) — 3.5M weekly downloads
- [@mapbox/geojson-rewind](https://npm.io/package/@mapbox/geojson-rewind.md) — 2.4M weekly downloads
- [turbo-stream](https://npm.io/package/turbo-stream.md) — 1.7M weekly downloads

## Recent versions

- 4.0.3 (latest) — 2026-03-05
- 4.0.2 — 2025-08-04
- 4.0.1 — 2025-07-02
- 4.0.0 — 2025-05-01
- 3.0.1 — 2024-12-10
- 3.0.0 — 2024-10-25
- 2.0.2 — 2023-07-03
- 2.0.1 — 2023-06-25
- 2.0.0 — 2023-05-14
- 1.0.1 — 2022-04-28
- 1.0.0 — 2021-10-14
- 0.3.0 — 2021-02-18
- 0.2.0 — 2021-02-09
- 0.1.1 — 2016-05-02
- 0.1.0 — 2015-10-05
- … 6 more at https://npm.io/package/json-text-sequence/versions

## README

# json-text-sequence

Parse and generate JSON text sequences as defined in [RFC 7464](https://tools.ietf.org/html/rfc7464).

JSON text sequences are nice for unambiguous JSON log files.  They are resilient
to many forms of damage such as truncation, multiple writers incorrectly
configured to write to the same file, corrupted JSON, etc.  An example sequence:

    ␞{"d":"2014-09-22T21:58:35.270Z","value":6}␤
    ␞{"d":"2014-09-22T21:59:15.117Z","value":12}␤

Where "␞" is the ASCII "Record Separator" character (U+001E), and "␤" is the
ASCII "LINE FEED" character (U+000A), otherwise known as "\n".

## Installation

    npm install json-text-sequence

## API

### Parsing

To parse the format, pipe an input source into a parser stream:

```js
import {Parser} from 'json-text-sequence'
import fs from 'fs'

const p = new Parser()
  .on('data', obj => {
    console.log('JSON:', obj);
  })
  .on('truncated', buf => {
    console.log('Truncated:', buf);
  })
  .on('invalid', buf => {
    console.log('Invalid:', buf);
  })
  .on('finish', () => {
    console.log('DONE');
  });

fs.createReadStream('example.log').pipe(p);
```

### Generation

To generate the format, create a generator, pipe its output somewhere
interesting, then write objects to the generator:

```js
import {Generator} from 'json-text-sequence'
import fs from 'fs'

const g = new Generator();
g.pipe(fs.createWriteStream('example.log'));

g.write({
  d: new Date(),
  count: 0
});
```

---
[![Tests](https://github.com/hildjj/json-text-sequence/workflows/Tests/badge.svg)](https://github.com/hildjj/json-text-sequence/actions?query=workflow%3ATests)
[![codecov](https://codecov.io/gh/hildjj/json-text-sequence/graph/badge.svg?token=eBBBlbwJLl)](https://codecov.io/gh/hildjj/json-text-sequence)

---
_Source: https://npm.io/package/json-text-sequence · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
