← Chrome 149 reference

v149 · javascript · covered on mdn

Uint8Array Base64 and Hex Methods

Six new methods on Uint8Array for converting raw bytes to and from base64 and hexadecimal strings without any third-party library — part of ECMAScript 2026 (TC39 Stage 4, archived October 2025).

this API is documented on MDN

MDN: Uint8Array.prototype.toBase64()

MDN documents all six methods with signatures, options, examples, and browser compatibility tables. The same namespace covers fromBase64, toHex, fromHex, setFromBase64, and setFromHex. gendn doesn't duplicate that reference here.

quick reference

MethodDirectionNotes
Uint8Array.prototype.toBase64(options?)bytes → stringalphabet: "base64" | "base64url"; omitPadding: boolean
Uint8Array.fromBase64(str, options?)string → bytesCreates new Uint8Array. lastChunkHandling: "loose" | "strict" | "stop-before-partial"
Uint8Array.prototype.setFromBase64(str, options?)string → existing bytesWrites into existing array; returns { read, written }
Uint8Array.prototype.toHex()bytes → stringLowercase hex, no options
Uint8Array.fromHex(str)string → bytesAccepts upper- and lowercase; creates new Uint8Array
Uint8Array.prototype.setFromHex(str)string → existing bytesWrites into existing array; returns { read, written }
Source: tc39/proposal-arraybuffer-base64 (archived October 28, 2025, part of ES2026).

quick examples

const bytes = new Uint8Array([72, 101, 108, 108, 111]); // "Hello"

// Encode
bytes.toBase64();          // 'SGVsbG8='
bytes.toBase64({ omitPadding: true }); // 'SGVsbG8'
bytes.toBase64({ alphabet: 'base64url' }); // 'SGVsbG8='
bytes.toHex();             // '48656c6c6f'

// Decode
Uint8Array.fromBase64('SGVsbG8=');
// Uint8Array [72, 101, 108, 108, 111]

Uint8Array.fromHex('48656c6c6f');
// Uint8Array [72, 101, 108, 108, 111]

// Write into an existing buffer (useful for streaming)
const target = new Uint8Array(10);
const { read, written } = target.setFromBase64('SGVsbG8=');
// read: 8 (base64 chars consumed), written: 5 (bytes written)
Source: tc39/proposal-arraybuffer-base64 README.

shipped in

Shipped inChrome 149
StandardECMAScript 2026 (TC39 Stage 4)
ChromeStatuschromestatus.com/feature/6281131254874112
TC39 proposaltc39/proposal-arraybuffer-base64