A streamed JSON document must be framed before parsing. A single JSON document and newline-delimited JSON have different boundaries.
Worked example
import {
Readable,
Writable,
Transform,
PassThrough,
isReadable,
isWritable,
} from "node:stream";
import { text, json, arrayBuffer } from "node:stream/consumers";
import { pipeline, finished } from "node:stream/promises";
console.log(await json(Readable.from(['{"n":', "7}"])));Result
{ n: 7 }Implementation notes
Parsing records one at a time requires a defined delimiter or frame. A newline inside formatted JSON is not always a record boundary.
Try it yourself
Split the sample just before a closing brace.
Open the Node.js example →Editorial date May 5, 2026 · Published December 6, 2026