JavaScript Base64 Encode and Decode: Encode and decode data in base64 format in pure JS

Recommend this page to a friend!
     
  Info   Example   View files Files   Download Download   Reputation   Support forum   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2025-07-09 (-4 hours ago) RSS 2.0 feedNot enough user ratingsTotal: 83 All time: 452 This week: 4Up
Version License JavaScript version Categories
base64 1.0.3GNU General Publi...5Text processing
Description 

Author

This object can encode and decode data in base64 format in pure JS.

It can take a data string and encode it using the base64 algorithm.

The object can also do the opposite, i.e. decode base64 encoded data and return the original data string.

Picture of Haseeb Ahmad Basil
  Performance   Level  
Name: Haseeb Ahmad Basil <contact>
Classes: 2 packages by
Country: Pakistan Pakistan
Age: 27
All time rank: 1492 in Pakistan Pakistan
Week rank: 6 Up1 in Pakistan Pakistan Up

Example

<html> <head> <script src="base64.min.js" type="text/javascript"></script> <script type="text/javascript"> var bs64 = new Base64(); var decoded = bs64.decode("VEVTVDEyMw=="); var encoded = bs64.encode("TEST123"); console.log('Encoded: ' + encoded); console.log('Decoded: ' + decoded); </script> </head> <body> <div id="example"></div> <script type="text/javascript"> var exmpl = document.getElementById('example'); exmpl.innerHTML = 'Encoded: ' + encoded + '<br />' + 'Decoded: ' + decoded; </script> </body> </html>

  Files folder image Files (6)  
File Role Description
Plain text file base64.js Class Class source
Plain text file base64.min.js Class Class source
Accessible without login Plain text file example.html Example EXAMPLE
Accessible without login Plain text file package.json Data Auxiliary data
Accessible without login Plain text file readme.md Doc. Documentation
Accessible without login Plain text file test.js Aux. Auxiliary script

 Version Control Unique User Downloads Download Rankings  
 100%
Total:83
This week:0
All time:452
This week:4Up