JavaScript - convert base64 to string

0 points
Created by:

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...


Base64 text:  c29tZSB0ZXh0Li4u
Decoded text: some text...

Related posts


  1. btoa() - Web APIs | MDN
Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.
Native Advertising
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂