Favorites

JavaScript ArrayBuffer Object

☕
Enjoying this site?

Help keep it running with a small coffee donation. Every bit of support is appreciated!

Buy us a coffee
ArrayBuffer
JavaScript Structured Data · ConstructorThis object is supported by all modern browsers.
Updated 28th November 2026

An ArrayBuffer is a fixed-length block of raw binary memory. You can't read it directly; you read and write it through a typed array or a DataView.

Description

An ArrayBuffer represents a block of raw binary data of a given number of bytes. It has no methods for reading its contents; instead you create a view over it, such as a Uint8Array or a DataView, which interprets the bytes as numbers of a certain type.

Binary data from fetch() responses, files and WebSockets often arrives as an ArrayBuffer. Buffers can be resizable (with the maxByteLength option and resize()), sliced into copies with slice(), and transferred to workers without copying.

An ArrayBuffer can be transferred to a web worker with postMessage(), which moves the memory instead of copying it and leaves the original buffer empty (detached). The transfer() method does the same within a single thread. To read text from a buffer, use TextDecoder, and to turn text into bytes, TextEncoder.

Creating

new ArrayBuffer(byteLength)
new ArrayBuffer(byteLength, { maxByteLength })

Example

const buffer = new ArrayBuffer(8);
console.log(buffer.byteLength);

const view = new Uint8Array(buffer);
view.set([1, 2, 3]);
console.log(view);

const copy = buffer.slice(0, 2);
console.log(new Uint8Array(copy));

Browser Support

The following information will show you the current browser support for the ArrayBuffer object. Hover over a browser icon to see the version that first introduced support for this object.

This object is supported by all modern browsers.

Desktop

Chrome
Edge
Firefox
Opera
Safari

Tablets & Mobile

Chrome Android
Firefox Android
Opera Android
Safari iOS
Samsung Internet
Android WebView
-
Supported Unknown Not supported
☕
Enjoying this site?

Help keep it running with a small coffee donation. Every bit of support is appreciated!

Buy us a coffee