Movatterモバイル変換


[0]ホーム

URL:


MDN Web Docs

Window: atob() method

BaselineWidely available

Theatob() method of theWindow interface decodes astring of data which has been encoded usingBase64 encoding. You can usetheWindow.btoa() method to encode and transmitdata which may otherwise cause communication problems, then transmit it and use theatob() method to decode the data again. For example, you can encode,transmit, and decode control characters such asASCII values 0 through 31.

Also consider using theUint8Array.fromBase64() method, which creates aUint8Array object from a base64-encoded string. It results in a byte array, which is easier to work with than a string containing raw bytes.

Syntax

js
atob(encodedData)

Parameters

encodedData

A base64-encoded string, using the alphabet produced byWindow.btoa().

Return value

A binary string containing raw bytes decoded fromencodedData. Strings in JavaScript are encoded asUTF-16, so this means each character must have a code point less than 256, representing one byte of data.

Exceptions

InvalidCharacterErrorDOMException

Thrown ifencodedData is not valid base64.

Examples

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

For more examples, see theWindow.btoa() method.

Specifications

Specification
HTML
# dom-atob-dev

Browser compatibility

See also

Help improve MDN

Learn how to contribute.

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2025 Movatter.jp