coderef

Uint8Array base64 and hex conversionBaseline · Newly available

The Uint8Array.fromBase64() static method and the toBase64() and setFromBase64() instance methods convert to and from base64 strings. Similarly, the Uint8Array.fromHex() static method and the toHex() and setFromHex() instance methods convert to and from hex strings.

Works in the latest version of every major browser, but older devices may not support it yet. Baseline since Sep 5, 2025.

Browser support

DesktopChrome
1–139Not supported
140+Supportedsince Sep 2, 2025
Current: 155
Edge
12–139Not supported
140+Supportedsince Sep 5, 2025
Current: 154
Firefox
1–132Not supported
133+Supportedsince Nov 26, 2024
Current: 157
Safari
1–18.1Not supported
18.2+Supportedsince Dec 11, 2024
Current: 27
MobileChrome Android
18–139Not supported
140+Supportedsince Sep 2, 2025
Current: 155
Firefox Android
4–132Not supported
133+Supportedsince Nov 26, 2024
Current: 157
Safari iOS
1–18.1Not supported
18.2+Supportedsince Dec 11, 2024
Current: 27

How to use

Every current browser supports this, but it only became Baseline on Sep 5, 2025. Use it as a progressive enhancement, or keep a fallback if you support older devices.

Example

Full syntax and examples are on MDN: fromBase64.

Feature detection

JS · check before using
if ("fromBase64" in Uint8Array || ("prototype" in Uint8Array && "fromBase64" in Uint8Array.prototype)) {
  // Uint8Array.fromBase64 is available
}

Sub-features

Support for each part of the feature (6). The overall table above shows when the whole feature works.

Sub-featureChromeEdgeFirefoxSafariChrome AndroidFirefox AndroidSafari iOS
Uint8Array.fromBase6414014013318.214013318.2
Uint8Array.fromHex14014013318.214013318.2
Uint8Array.setFromBase6414014013318.214013318.2
Uint8Array.setFromHex14014013318.214013318.2
Uint8Array.toBase6414014013318.214013318.2
Uint8Array.toHex14014013318.214013318.2