You are here: Reference > JavaScript > client-side > HTML DOM > methods > atob (window)

atob method (window)

Browser support:
Decodes a base-64 encoded string.
Use the btoa method to encode a string in base-64. The btoa method uses the A-Z, a-z, 0-9, +, / and = characters for encoding a string.

Syntax:

object.atob (dataToDecode);
You can find the related objects in the Supported by objects section below.

Parameters:

dataToDecode
Required. String that specifies the base-64 encoded data to decode.

Return value:

Returns the decoded string.

Example HTML code 1:

This example illustrates the use of the atob method:
<head>
    <script type="text/javascript">
        function EncodeDecode () {
            input = document.getElementById ("myInput");

            encodedData = window.btoa (input.value);
            alert ("encoded data: " + encodedData);

            decodedData = window.atob (encodedData);
            alert ("decoded data: " + decodedData);
        }
    </script>
</head>
<body>
    <input type="text" id="myInput" value="The text to encode"/>
    <button onclick="EncodeDecode ();">Encode in base-64!</button>
</body>
Did you find this example helpful? yes no

Supported by objects:

Related pages:

External links:

User Contributed Comments

Post Content

Post Content