demo ยท v138

Format options lab

The base64 methods take an alphabet ("base64" or "base64url"), an omitPadding flag, and the parser accepts a lastChunkHandling option ("loose", "strict", "stop-before-partial"). This lab exercises every combination, round-trips, and shows you the failure modes.

Unflagged in Chrome 138. Uint8Array.prototype.toBase64 / fromBase64 / toHex / fromHex with full options dictionary support โ€” matches the TC39 stage-3 proposal.
probing Uint8Array.fromBase64…

Encode side

toBase64() output

โ€”

toHex() output

โ€”

Decode side ยท lastChunkHandling

fromBase64() output

โ€”

round-trip back to base64

โ€”
โ€”

The API surface

// Encode
bytes.toBase64({ alphabet: 'base64' | 'base64url', omitPadding: boolean });
bytes.toHex();

// Decode
Uint8Array.fromBase64(str, {
  alphabet: 'base64' | 'base64url',
  lastChunkHandling: 'loose' | 'strict' | 'stop-before-partial',
});
Uint8Array.fromHex(str);

// Streaming variants (write into existing buffer)
const written = bytes.setFromBase64(str, options);   // { read, written }

see also