Window: atob() method - Web APIs | MDN (original) (raw)
Syntax
Parameters
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
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
- A polyfill of atob is available in core-js
- data URLs
- WorkerGlobalScope.atob(): the same method, but in worker scopes.
- Window.btoa()
- Uint8Array.fromBase64()