Import
Functions
b64encode()
Encodes data in base64 format.The input string or ArrayBuffer object to base64 encode.
The base64 encoding to use:
"std"- Standard encoding with=padding and+//characters (default)"rawstd"- Standard encoding without=padding"url"- URL-safe encoding with-/_instead of+//"rawurl"- URL-safe encoding without=padding
The base64 encoding of the input data.
b64decode()
Decodes a base64 encoded string into the original unencoded input.The string to base64 decode.
The base64 encoding to use:
"std"- Standard encoding with=padding and+//characters (default)"rawstd"- Standard encoding without=padding"url"- URL-safe encoding with-/_instead of+//"rawurl"- URL-safe encoding without=padding
Output format:
"s"- Return as string- Unspecified - Return as ArrayBuffer (default)
The base64 decoded version of the input in either string or ArrayBuffer format.
Encoding Types
Standard (std)
Default base64 encoding with
= padding characters and +// in the alphabet.Raw Standard (rawstd)
Standard encoding without
= padding characters.URL-safe (url)
URL-safe encoding using
- and _ instead of + and /, with padding.Raw URL-safe (rawurl)
URL-safe encoding without
= padding characters.Use Cases
- Encoding binary data for HTTP headers or URLs
- Encoding authentication credentials (Basic Auth)
- Working with Base64-encoded API payloads
- Converting between binary and text representations
- Handling file uploads as base64 strings
Use URL-safe encoding (
url or rawurl) when the encoded data will be used in URLs or filenames to avoid special characters.