Window atob() Method - Javascript Browser Object Model

Javascript examples for Browser Object Model:Window atob


The atob() method decodes a base-64 encoded string which has been encoded by the btoa() method.

Parameter Values

Parameter Description
encodedStr Required. The string which has been encoded by the btoa() method

Return Value:

A String, representing the decoded string

The following code shows how to Decode a base-64 encoded string:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>

<button onclick="myFunction()">Test</button>

<p id="demo"></p>

function myFunction() {/*from w  w  w  .  j a  v a2 s  .  c  om*/
    var str = "Hello World!";
    var enc = window.btoa(str);
    var dec = window.atob(enc);

    var res = "Encoded String: " + enc + "<br>" + "Decoded String: " + dec;
    document.getElementById("demo").innerHTML = res;


Related Tutorials