MDN Web Docs

Syntax

js

atob(encodedData)

Parameters

encodedData

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

Return value

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

Exceptions

InvalidCharacterError DOMException

Thrown if encodedData is not valid base64.

Examples

js

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

For more examples, see the Window.btoa() method.

Specifications

Specification
HTML
# dom-atob-dev

Browser compatibility

See also

Help improve MDN

Yes No

Learn how to contribute

This page was last modified on by MDN contributors.

Read the original on developer.mozilla.org ↗