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:
xxxxxxxxxx
1
const encoded = 'c29tZSB0ZXh0Li4u';
2
3
const decoded = atob(encoded);
4
console.log('Converted text: ' + decoded); // some text...
In this example, we use atob()
method to decode Base64-encoded ASCII string.
xxxxxxxxxx
1
const encoded = 'c29tZSB0ZXh0Li4u';
2
3
// convert base64 to string
4
const decoded = atob(encoded);
5
6
console.log('Base64 text: ' + encoded); // c29tZSB0ZXh0Li4u
7
console.log('Decoded text: ' + decoded); // some text...
Output:
xxxxxxxxxx
1
Base64 text: c29tZSB0ZXh0Li4u
2
Decoded text: some text...