Skip to content
NewBun 1.4.5 is out. Release notes
AphrodyBun

Guides · Streams

Convert a Node.js Readable to JSON

Parse the contents of a Node.js Readable stream as JSON by wrapping it in a Response and calling .json().

To convert a Node.js Readable stream to a JSON object in Bun, create a Response with the stream as the body, then call response.json().

import { Readable } from "stream";
const stream = Readable.from([JSON.stringify({ hello: "world" })]);
const json = await new Response(stream).json();
console.log(json); // { hello: "world" }