The WindowOrWorkerGlobalScope.atob()
function decodes a string of data which has been encoded using base-64 encoding. You can use the btoa()
method to encode and transmit data which may otherwise cause communication problems, then transmit it and use the atob()
method to decode the data again. For example, you can encode, transmit, and decode control characters such as ASCII values 0 through 31.
For use with Unicode or UTF-8 strings, see this note at Base64 encoding and decoding and this note at btoa()
.
var decodedData = scope.atob(encodedData);
Throws a DOMException
if encodedData is not valid base64.
var encodedData = window.btoa('Hello, world'); // encode a string var decodedData = window.atob(encodedData); // decode the string
Specification | Status | Comment |
---|---|---|
HTML Living Standard The definition of 'WindowOrWorkerGlobalScope.atob()' in that specification. | Living Standard | Method moved to the WindowOrWorkerGlobalScope mixin in the latest spec. |
HTML 5.1 The definition of 'WindowBase64.atob()' in that specification. | Recommendation | Snapshot of HTML Living Standard. No change. |
HTML5 The definition of 'WindowBase64.atob()' in that specification. | Recommendation | Snapshot of HTML Living Standard. Creation of WindowBase64 (properties were on the target before it). |
Desktop | ||||||
---|---|---|---|---|---|---|
Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | |
Basic support | Yes | Yes | 1
|
10 | Yes | Yes |
Mobile | |||||||
---|---|---|---|---|---|---|---|
Android webview | Chrome for Android | Edge Mobile | Firefox for Android | Opera for Android | iOS Safari | Samsung Internet | |
Basic support | Yes | Yes | ? | 4
|
? | Yes | ? |
© 2005–2018 Mozilla Developer Network and individual contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/atob