Base64 Encode and Decode in Javascript

guptasanchit90

Sanchit Gupta

Posted on November 1, 2021

Base64 Encode and Decode in Javascript

See it in Action - https://www.apps4developers.com/base64

Converting Plain Text to Base64 Encoded String

btoa() generates a Base64 encoded ASCII string from plain text. This method is useful to encode text that is not in a URL-safe format.

Passing a string to btoa method will return a Base64 encoded string.

Example

btoa("Apps4Developers.com")
Enter fullscreen mode Exit fullscreen mode

---

Converting Base64 Encoded String to Plain Text

atob() method is used to convert Base64 encoded ASCII string to plain text.

Passing a Base64 encoded ASCII string to atob method will return plain text.

Example

atob("AkFwcHM0RGV2ZWxvcGVycy5jb20=")
Enter fullscreen mode Exit fullscreen mode
💖 💪 🙅 🚩
guptasanchit90
Sanchit Gupta

Posted on November 1, 2021

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related