EN
JavaScript - convert base64 to string
0
points
In this article, we would like to show you how to convert Base64 to string in JavaScript.
Quick solution:
// ONLINE-RUNNER:browser;
const encoded = 'c29tZSB0ZXh0Li4u';
const decoded = atob(encoded);
console.log('Converted text: ' + decoded); // some text...
Practical Example
In this example, we use atob() method to decode Base64-encoded ASCII string.
// ONLINE-RUNNER:browser;
const encoded = 'c29tZSB0ZXh0Li4u';
// convert base64 to string
const decoded = atob(encoded);
console.log('Base64 text: ' + encoded); // c29tZSB0ZXh0Li4u
console.log('Decoded text: ' + decoded); // some text...
Output:
Base64 text: c29tZSB0ZXh0Li4u
Decoded text: some text...