# @oresoftware/json-stream-parser

> Parse JSON streams into JS objects.

Latest version **0.1.136** (published 2026-06-03) · SEE LICENSE IN license.md license · 0 weekly downloads

## Install

```sh
npm install @oresoftware/json-stream-parser
pnpm add @oresoftware/json-stream-parser
yarn add @oresoftware/json-stream-parser
bun add @oresoftware/json-stream-parser
```

Provides the command `json_parser`.

## Health

**Score 65/100 (B)** — status: active.

Positive: has types; esm support; no vulnerabilities; high maintenance score; high quality score.

Warnings: low downloads; pre 1.0.

## Facts

| | |
|---|---|
| Version | 0.1.136 |
| Published | 2026-06-03 |
| First published | 2018-09-18 |
| Weekly downloads | 0 |
| License | SEE LICENSE IN license.md |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 25.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | Olegzandr von Denman |
| Maintainers | oresoftware |
| Keywords | typescript, library, skeleton, scaffold |

## Links

- npm: https://www.npmjs.com/package/@oresoftware/json-stream-parser
- Repository: https://github.com/ORESoftware/json-parser
- Homepage: https://github.com/ORESoftware/json-parser#readme
- Issues: https://github.com/ORESoftware/json-parser/issues
- npm.io page: https://npm.io/package/@oresoftware/json-stream-parser

## Alternatives

- [@openai/codex-sdk](https://npm.io/package/@openai/codex-sdk.md) — 731.4K weekly downloads
- [babel-plugin-transform-react-jsx](https://npm.io/package/babel-plugin-transform-react-jsx.md) — 565.0K weekly downloads
- [babel-helper-remove-or-void](https://npm.io/package/babel-helper-remove-or-void.md) — 508.5K weekly downloads
- [@pnpm/store-controller-types](https://npm.io/package/@pnpm/store-controller-types.md) — 186.9K weekly downloads
- [react-native-signature-canvas](https://npm.io/package/react-native-signature-canvas.md) — 155.6K weekly downloads

## Recent versions

- 0.1.136 (latest) — 2026-06-03
- 0.1.135 — 2026-06-02
- 0.0.124 — 2019-10-07
- 0.0.123 — 2019-09-10
- 0.0.121 — 2019-08-12
- 0.0.120 — 2019-07-31
- 0.0.119 — 2019-07-31
- 0.0.118 — 2019-07-31
- 0.0.117 — 2019-07-17
- 0.0.116 — 2019-07-17
- 0.0.115 — 2019-07-17
- 0.0.114 — 2019-07-13
- 0.0.113 — 2019-05-07
- 0.0.111 — 2019-05-07
- 0.0.110 — 2019-04-11
- … 8 more at https://npm.io/package/@oresoftware/json-stream-parser/versions

## README

## @oresoftware/json-stream-parser

[![Version](https://img.shields.io/npm/v/@oresoftware/json-stream-parser.svg?colorB=green)](https://www.npmjs.com/package/@oresoftware/json-stream-parser)


### Transform stream

>
>  Transforms JSON stream to JS Objects
>

### Installation

```bash

$ npm install '@oresoftware/json-stream-parser'

```

### Import

```js

import {JSONParser} from '@oresoftware/json-stream-parser';

```

### Import (CommonJS)

```js

const {JSONParser} = require('@oresoftware/json-stream-parser');

```

### Usage

Right now, the library assumes each separate chunk of json is separated by newline characters. <br>
In the future, we could attempt to use a different delimiting character, as a user-provided input variable. <br>
Recommendations welcome.


## Examples

#### Simple Node.js example:

###### Reading from stdin

```typescript

process.stdin.resume().pipe(new JSONParser()).on('data', d => {
  // now we got some POJSOs!
});

```

###### Reading/writing to a tcp socket

```typescript

import * as net from 'net';
const [port,host] = [6970,'localhost'];
const ws = net.createConnection(port, host);

ws.setEncoding('utf8')
  .pipe(new JSONParser())   // tcp connection is bidirection/full-duplex .. we send JSON strings each way
  .on('data', onData);    // we receive data coming from the tcp server here


// and we send data like this:
ws.write(JSON.stringify({'some':'data'}) + '\n', 'utf8', cb); // make sure to include the newline char when you write

```

#### Using bash shell

###### Simple bash example:

```js

const k = cp.spawn('bash');
k.stdin.end(`echo '{"foo":"bar"}\n'`);  // make sure to include the newline char when you write

k.stdout.pipe(new JSONParser()).on('data', d => {
  // => {foo: 'bar'}
});

```

###### Bash example with bash variables:

```js

const k = cp.spawn('bash');

k.stdin.end(`

  foo="medicine"
  cat <<EOF\n{"foo":"$foo"}\nEOF  # make sure to include the newline char when you write

`);

k.stdout.pipe(new JSONParser()).on('data', d => {
    assert.deepStrictEqual(d, {foo: 'medicine'});  // should pass
});


```

### If your JSON has white space (newlines etc)

If you JSON has unescaped newlines, or the JSON is separated by some other character, then use the delimiter option.

```js
new JSONParser({delimiter: '∆∆∆'});  // use 3 alt-j's to separate json chunks, since newlines won't work

```

For other solutions to parsing JSON from CLIs, see:
https://stackoverflow.com/questions/56014438/get-single-line-json-from-aws-cli



### Other options

1. delayEvery: integer  

> JSONParser delays the transform callback every x chunks. LiveMutexJSONParser delays every x non-empty JSON records, which is better for long JSONL chunks that should not monopolize the event loop.

```js
import {LiveMutexJSONParser, createLiveMutexJSONParser} from '@oresoftware/json-stream-parser';

const parser = new LiveMutexJSONParser({delayEvery: 1024});
const parserWithDefaultDelay = createLiveMutexJSONParser();
```


2. emitNonJSON: boolean

> if there is a line of input that cannot be JSON parsed, it will be emitted as "string", but it will not pushed to output


3. there are some secret options in the code, have a look in `lib/main.ts`

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