Some browsers such as Firefox, Chrome, Safari, Opera and IE10+ can handle Base64 natively. Take a look at this Stackoverflow question. It's using btoa() and atob() functions.
btoa()
atob()
For server-side JavaScript (Node), you can use Buffers to decode.
Buffer
If you are going for a cross-browser solution, there are existing libraries like CryptoJS or code like:
http://ntt.cc/2008/01/19/base64-encoder-decoder-with-javascript.html
With the latter, you need to thoroughly test the function for cross browser compatibility. And error has already been reported.
2.1m questions
2.1m answers
60 comments
57.0k users