Window atob() in JavaScript

Learn via video course
FREE
View all courses
JavaScript Course With Certification: Unlocking the Power of JavaScript
JavaScript Course With Certification: Unlocking the Power of JavaScript
by Mrinal Bhattacharya
1000
4.8
Start Learning
JavaScript Course With Certification: Unlocking the Power of JavaScript
JavaScript Course With Certification: Unlocking the Power of JavaScript
by Mrinal Bhattacharya
1000
4.8
Start Learning
Topics Covered

Overview

The Window atob() in JavaScript is used to decode a base-64 encoded string. atob in the JS method is used for decoding data encoded with btoa(). Decoding returns a string representing the decoded string.

Syntax of Window atob() in JavaScript

The syntax of Window atob() in JavaScript is given as:

Parameters of Window atob() in JavaScript

The following parameter of atob in JS is:

encodedData - The string which is to be decoded. It is a binary string that contains base64-encoded data. In a binary string, each character is treated as a byte of binary data.

It is mandatory to provide a parameter to the Window atob() in JavaScript.

Return Value of Window atob() in JavaScript

atob in JS returns decoded data from encodedData as an ASCII string.

Exceptions of Window atob() in JavaScript

InvalidCharacterError - Window atob() in JavaScript throws an error when the encodedData is not a valid base64 string.

Base64 string is an encoded string that represents binary data in an ASCII string

Example

Output

What is Window atob() in JavaScript?

Window atob() in JavaScript decodes a string of data encoded with Base64 encoding using the atob() function.

To encode and transmit data that may otherwise cause communication problems, you can then use the btoa() method to encode your data, then transmit it and use the atob() method to decode it again.

More Examples

The example below illustrates the use of the Window atob() in JavaScript.

Output

output-use-of-window-atob

Supported Browsers

Window atob() in JavaScript supports the following browsers:

BrowserVersion
Edge12
Internet Explorer10
Opera10.5
Firefox1
Safari3
Google Chrome4

Conclusion

  • The Window atob() in JavaScript stands for ASCII to binary.
  • A base-64 encoded string can be decoded with the Window atob() in JavaScript.
  • The parameter passed onto the Window atob() in JavaScript must be a valid base64 string.
  • A base64 string is an encoded string that represents binary data in an ASCII string.
  • It returns the decoded string.
  • The atob() and btoa() methods allow developers to transform data to and from the base64 encoding.