Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

Window btoa() method

Window btoa() method

Window Object Reference Window Object


Definition and Usage

The btoa() method is used to create a base-64 encoded string.

This method uses the characters "A-Z", "a-z", "0-9", "+", "/" and "=" to encode the string.

The base-64 decoding usage is atob() .

Syntax



window.btoa(str)

Parameter Description:

Return Value

This method returns a base-64 encoded string


Browser support

The numbers in the table indicate the first browser version that supports this method.

Method
btoa() Yes 10.0 1.0 Yes Yes

Example

Example

Create a base-64 encoded string:

var

str

=

"

RUNOOB

"

;

var

enc

=

window

.

btoa

(

str

)

;

var

res

=

"

Encoded string:

"

enc

;

Try it »


Window Object Reference Window Object