Encode a string in base-64:
let text = "Hello World!";
let encoded = window.btoa(text);
Try it Yourself »
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.
window.btoa(
string)
Parameter | Description |
string | Required. The string to be encoded. |
Type | Description |
A string | The base-64 encoded string. |
btoa()
is supported in all browsers:
Chrome | IE | Edge | Firefox | Safari | Opera |
Yes | 10-11 | Yes | Yes | Yes | Yes |
截取页面反馈部分,让我们更快修复内容!也可以直接跳过填写反馈内容!