Skip to content
masterclassBuddyTech Buzz5 fresh blogs · 5:00 AM IST

Node.js · Class

Blob

Blob encapsulates immutable raw data that can be safely shared across worker threads. It combines string or binary parts and supports byte, text, ArrayBuffer, and stream-based reads.

Since
v18.0.0

How it works

The global Blob class stores immutable raw data assembled from strings or binary parts. Its size and MIME type are available synchronously; arrayBuffer(), bytes(), text(), and stream() provide asynchronous or streaming access to the content, while the original data remains safely shareable across worker threads.

Syntax

new buffer.Blob([sources[, options]])

Parameters

NameTypeDescription
sourcesstring[] | ArrayBuffer[] | TypedArray[] | DataView[] | Blob[]Array of strings, ArrayBuffer, TypedArray, DataView, or Blob values to concatenate into the new Blob.
optionsObjectOptional settings. endings may be transparent or native; type specifies the content type.

Returns

A Blob instance containing the concatenated source data.

Key points

  • Blob represents immutable raw data suitable for safe sharing between worker threads.
  • The constructor combines all supplied parts in order into one Blob.
  • The size property reports the Blob's byte length.
  • The type property exposes the configured MIME content type.
  • bytes() asynchronously returns the content as a Uint8Array.
  • stream() exposes Blob content through a ReadableStream.

Common mistakes

  • String parts are encoded as UTF-8 and copied, so later changes to the original string source cannot affect the Blob.
  • arrayBuffer() returns copied data rather than a view into the Blob's internal storage.
  • Worker messaging can share a Blob without immediate transfer or copying; copying occurs when arrayBuffer() or text() is called.

Example: Create and read a Blob

const blob = new Blob(["hello", " world"], { type: "text/plain" });

console.log(blob.size, blob.type);
console.log(await blob.text());

const bytes = await blob.bytes();
console.log(bytes.length);

Creates a text Blob, inspects its metadata, reads it as UTF-8 text, and obtains its bytes.

When to use it

Binary and text payloads

Representing request or response payloads with an explicit MIME type.

Worker communication

Passing immutable data between worker threads through MessagePort.

Flexible data access

Reading content as bytes, UTF-8 text, an ArrayBuffer, or a stream.

  • Blob.prototype.arrayBuffer()
  • Blob.prototype.bytes()
  • Blob.prototype.stream()
  • Blob.prototype.text()
  • MessagePort

Source: Buffer | Node.js v26.4.0 Documentation. Checked 2026-10-15.