Please note, this is a STATIC archive of website developer.mozilla.org from 03 Nov 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

이 글은 기술 검토가 필요합니다. 도울을 줄 수 있는 방법을 살펴보세요.

이 문서는 아직 자원 봉사자들이 한국어로 번역하지 않았습니다. 함께 해서 번역을 마치도록 도와 주세요!

The WindowBase64.atob() function decodes a string of data which has been encoded using base-64 encoding. You can use the window.btoa() method to encode and transmit data which may otherwise cause communication problems, then transmit it and use the window.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 window.btoa().

Syntax

var decodedData = window.atob(encodedData);

Throws

Throws a DOMException if the length of passed-in string is not a multiple of 4.

Example

var encodedData = window.btoa("Hello, world"); // encode a string
var decodedData = window.atob(encodedData); // decode the string

Specifications

Specification Status Comment
WHATWG HTML Living Standard
The definition of 'WindowBase64.atob()' in that specification.
Living Standard No change since the latest snapshot, HTML5.1.
HTML5.1
The definition of 'WindowBase64.atob()' in that specification.
Working Draft Snapshot of WHATWG HTML Living Standard. No change.
HTML5
The definition of 'WindowBase64.atob()' in that specification.
Recommendation Snapshot of WHATWG HTML Living Standard. Creation of WindowBase64 (properties were on the target before it).

Browser compatibility

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari (WebKit)
Basic support (Yes) 1.0 (1.7 or earlier)[1]
27 (27)[2]
10 (Yes) (Yes)
Feature Android Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
Basic support (Yes) 1.0 (1) No support ? (Yes)

[1] atob() is also available to XPCOM components implemented in JavaScript, even though window is not the global object in components.

[2] Starting with Firefox 27, atob() ignores all space characters in the argument to comply with the latest HTML5 spec. (bug 711180)

See also