Dev Helpers

Node.js / Web response APIs

Decode a response body

Dev Helpers · March 7, 2026

A response body is a consumable stream. Choose how to decode it before handing it to several readers.

Worked example

import { Blob } from "node:buffer";
console.log(await new Response("message").text());

Result

message

Implementation notes

A streamed response may be large. If only the first records are needed, reading the full text first can erase the memory advantage of streaming.

Try it yourself

Read the same response twice and compare that with reading a clone.

Open the Node.js example →

Editorial date March 7, 2026 · Published December 6, 2026

Related articles

Safely parse malformed input

Parsing user-provided JSON needs a failure path. Successful parsing alone does not establish that the result has the expected shape.

Checksum bytes with CRC32

CRC32 is useful for detecting accidental changes to a byte sequence. Record the input encoding so different producers compute the same checksum.

Attach details to a mark

Performance marks can carry details about the operation they describe. Small stable identifiers are easier to aggregate than large payloads.