Base64 Encode and Decode String Online

Some of the links are affiliate links and I earn commission from them. Moreover, as an Amazon Associate, I earn from qualifying purchases.

Do you want to store any string or text secretly, so that no one can read the actual text? Well, an easy way to do that is to use base64 to encode and decode the encoded string with base64 whenever you want to read it.

In this post, we have an online convertor using which you can encode a string with Base64. Additionally, you can use another convertor tool to decode the same string.

What Is Base64 encode and decode?

Base 64 is an encoding scheme that takes binary information and changes it into complex text by translating the data to a radix-64 representation. The reversal process is called decode.

The below table shows the binary data and its respective base64 character.

Padding =

How To Use Base64 encode decode in Programming Language

You can use the above tool base64 encoding and decoding without having knowledge of programming language. However, the below section describes the code you can use to encode and decode base64.

Base64 Encode In JavaScript

Javascript is a very popular language. In fact, the above Base64 encoder and decoder are built with Javascript only. In javascript, you can use window.btoa(“string”) to encode a string in Base64 whereas to decode you can use window.atob(“string”).

<input type="textarea" name="inputtext" id="encode">
<button onclick="myFunction1()">Encode Base64</button>
<input type="textarea" name="inputtext" id="decode">
<button onclick="myFunction2()">Decode Base64</button>

<p id="demo1"></p>
<p id="demo2"></p>

function myFunction1() {
  var str = document.getElementById("encode").value;
  var enc = window.btoa(str);

  var res = "Encoded String: " + enc;
  document.getElementById("demo1").innerHTML = "The original string: " + str + "<br>" + res;

function myFunction2() {
  var str = document.getElementById("decode").value;
  var enc = window.atob(str);

  var res = "Encoded String: " + enc;
  document.getElementById("demo2").innerHTML = "The original string: " + str + "<br>" + res;

Encode and Decode String With Base64 using Python

Python has an inbuilt library called Base64 for encoding and decoding strings. First, you have to import the library, convert the strings to byte-like objects, and then encode it using the base64 library. Follow the exact reverse process to decode the strings.

>>> import base64
>>> string = "techieblogging"
>>> string_bytes = string.encode("ascii")
>>> base64_bytes = base64.b64encode(string_bytes)
>>> base64_string = base64_bytes.decode("ascii")
>>> print(f"Encoded string: {base64_string}")
Output: Encoded string: dGVjaGllYmxvZ2dpbmc=
>>> #decoding string
>>> base64_string ="dGVjaGllYmxvZ2dpbmc="
>>> base64_bytes = base64_string.encode("ascii")
>>> string_bytes = base64.b64decode(base64_bytes)
>>> string = string_bytes.decode("ascii")
>>> print(f"Decoded string: {string}")
Output: Decoded string: techieblogging

Base64 encoding and Decoding using PHP

In this post, we will see the PHP code using which you can encode and decode a string using base64. Like many programming languages, PHP has inbuilt libraries to perform encoding and decoding. In PHP language you perform base64 encode using base64_encode(“string”). Similarly, you can use base64_decode(“string”) to decode an encoded string.

<!DOCTYPE html>

// PHP code to encode strings

$str = 'techieblogging';
echo base64_encode($str);

// PHP code to decode strings

$str = 'dGVjaGllYmxvZ2dpbmc=';

echo base64_decode($str);


What is the use of base64 encoding?

There are various ways you can use base64 encoding. One of the widely used scenarios is sending email attachments over email. The email software usually converts the attachment into a base64 encoded string and sends it over communication channels.

You can also use this approach to store confidential data. Though it is not powerful as encryption, still a better approach to store confidential data such as user name and password.


I Hope, the online base64 encoder and decoder will be useful to you in your day-to-day activities. Though it is not a replacement for encryption still a good approach for many cases.

If you feel any improvement is necessary, feel free to tell us in the comment section.

Visit Home Page
0 0 votes
Rate Us
Notify of
Inline Feedbacks
View all comments
Web Hosting + Free Domain At $1.2/mo Use Coupon Code SOLARRAID85Click Here
+ +
Would love your thoughts, please comment.x