Window btoa()
Example
Encode a string in base-64:
let text = "Hello World!";
let encoded = window.btoa(text);
Try it Yourself »
Description
The btoa()
method encodes a string in base-64.
The btoa()
method uses the "A-Z", "a-z", "0-9", "+", "/" and "=" characters to encode the string.
Syntax
window.btoa(string)
Parameters
Parameter | Description |
string | Required. The string to be encoded. |
Return Value
Type | Description |
A string | The base-64 encoded string. |
Browser Support
btoa()
is supported in all browsers:
Chrome | IE | Edge | Firefox | Safari | Opera |
Yes | 10-11 | Yes | Yes | Yes | Yes |