Window btoa() method

Definition and Usage

btoa() This method encodes a string in base-64.

btoa() This method encodes the string using the characters "A-Z", "a-z", "0-9", "+", "/", and "=".

Tip:Use atob() method This method decodes a base-64 encoded string.

See also:

atob() method

Example

Encode string in base-64:

let text = "Hello World!";
let encoded = window.btoa(text);

Try it yourself

Syntax

window.btoa(string)

Parameter

Parameter Description
string Required. The string to be encoded.

Return value

Type Description
Chaîne Chaîne codée en base-64.

Support du navigateur

Tous les navigateurs le supportent btoa()

Chrome IE Edge Firefox Safari Opera
Chrome IE Edge Firefox Safari Opera
Support 10-11 Support Support Support Support