fromBase64
Decodes Base64 text. Both alphabets are accepted (+/ and the URL-safe -_) and the =
padding is optional, so it reads whatever toBase64 wrote, and most Base64 found in the wild.
Available since v3.1.8
Import
Section titled “Import”Signature
Section titled “Signature”Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
text | string | The Base64 text, without whitespace |
options | FromBase64Options & object | `{ output: ‘bytes’ }` to get a `Uint8Array` instead of a string |
Returns
Section titled “Returns”Uint8Array — The decoded text (UTF-8), or the bytes
Examples
Section titled “Examples”Decode Base64 to text
Section titled “Decode Base64 to text”Either alphabet is accepted and the padding is optional.
Decode to raw bytes
Section titled “Decode to raw bytes”Use output: bytes when the payload is not text.
Related Types
Section titled “Related Types”FromBase64Options
Section titled “FromBase64Options”Options for fromBase64.
