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: 155Edge
12–139Not supported
140+Supportedsince Sep 5, 2025
Current: 154Firefox
1–132Not supported
133+Supportedsince Nov 26, 2024
Current: 157Safari
1–18.1Not supported
18.2+Supportedsince Dec 11, 2024
Current: 27MobileChrome Android
18–139Not supported
140+Supportedsince Sep 2, 2025
Current: 155Firefox Android
4–132Not supported
133+Supportedsince Nov 26, 2024
Current: 157Safari iOS
1–18.1Not supported
18.2+Supportedsince Dec 11, 2024
Current: 27How 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-feature | Chrome | Edge | Firefox | Safari | Chrome Android | Firefox Android | Safari iOS |
|---|---|---|---|---|---|---|---|
| Uint8Array.fromBase64 | 140 | 140 | 133 | 18.2 | 140 | 133 | 18.2 |
| Uint8Array.fromHex | 140 | 140 | 133 | 18.2 | 140 | 133 | 18.2 |
| Uint8Array.setFromBase64 | 140 | 140 | 133 | 18.2 | 140 | 133 | 18.2 |
| Uint8Array.setFromHex | 140 | 140 | 133 | 18.2 | 140 | 133 | 18.2 |
| Uint8Array.toBase64 | 140 | 140 | 133 | 18.2 | 140 | 133 | 18.2 |
| Uint8Array.toHex | 140 | 140 | 133 | 18.2 | 140 | 133 | 18.2 |