Cover Image for Base64 Decoding In JavaScript
157 views

Base64 Decoding In JavaScript

To decode a Base64 encoded string in JavaScript, you can use the atob() function. Here’s an example:

JavaScript
const base64String = 'SGVsbG8gV29ybGQ=';

const decodedString = atob(base64String);

console.log(decodedString); // Output: "Hello World"

In this example, the atob() function is used to decode the Base64 encoded string stored in the base64String variable. The decoded result is stored in the decodedString variable.

The atob() function is a built-in JavaScript function that decodes a Base64 encoded string. It takes the Base64 string as an argument and returns the decoded string. The decoded string can contain any type of data, including text, binary, or even image data.

Please note that the atob() function is available in modern web browsers and Node.js environments. If you are working with older browsers or environments that do not support atob(), you can use a polyfill or a third-party library like base64-js or js-base64 to perform Base64 decoding.

YOU MAY ALSO LIKE...

The Tech Thunder

The Tech Thunder

The Tech Thunder


COMMENTS