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.

Note

Use the The atob() method to decode a base-64 encoded string.

See Also:

The atob() Method.


Syntax

window.btoa(string)

Parameters

Parameter Description
string Required.
The string to be encoded.

Return Value

Type Description
A stringThe 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


Copyright 1999-2023 by Refsnes Data. All Rights Reserved.