Base64 Encode online

Latest From The Blog

About Base64Encoder

Base64Encoder.io is a simple and easy-to-use online tool to encode any binary or text data to Base64 encoded format.

You can get started by typing or pasting any string in the input textarea, the tool will convert the entered data to Base64 encoded format in real time. Once the data is encoded, you can click in the output textarea to copy the encoded data.

You can also convert an Image to Base64 encoded data using our Image to Base64 converter tool.

The website also contains several tutorials and articles about Base64 encoding and how to Base64 encode any binary or text data in different programming languages like Java, Go, PHP, Python, and Javascript.

What is Base64 Encoding and why is it used?

Base64 encoding is a way to convert any binary or text data into printable ASCII string format.

It is needed to safely transmit binary data over a transmission protocol/medium that does not support/handle binary data correctly.

Note that, Base64 is not an encryption or compression scheme. It is an encoding scheme that converts binary data like image or file to the ASCII character set.

It is called Base64 because it works with a subset of 64 characters from the ASCII character set. These characters include upper and lowercase alphabets (A-Za-z), digits (0-9), +, and /.

These 64 characters form the Base64 alphabet. Note that, the Base64 encoding scheme also uses an extra 65th character = as pad character.

# The Base64 alphabet/lookup table
Value Base64    Value Base64    Value Base64    Value Base64
    0 A            17 R            34 i            51 z
    1 B            18 S            35 j            52 0
    2 C            19 T            36 k            53 1
    3 D            20 U            37 l            54 2
    4 E            21 V            38 m            55 3
    5 F            22 W            39 n            56 4
    6 G            23 X            40 o            57 5
    7 H            24 Y            41 p            58 6
    8 I            25 Z            42 q            59 7
    9 J            26 a            43 r            60 8
   10 K            27 b            44 s            61 9
   11 L            28 c            45 t            62 +
   12 M            29 d            46 u            63 /
   13 N            30 e            47 v
   14 O            31 f            48 w         (pad) =
   15 P            32 g            49 x
   16 Q            33 h            50 y

How does Base64 encoding algorithm work?

Base64 encoding is multi-step process. But it is very simple. Here is how it works -

  1. Convert the input to 8-bit bytes
  2. Re-group the input to 6-bit groups.
  3. Find the decimal equivalent of the 6-bit groups.
  4. Use the Base64 alphabet table to find the character corresponding to the decimal values.
  5. If the input can’t be grouped into an integral number of 6-bit groups, then one or two pad character is added to the output based on the following conditions:

    • If the last group contains 2 bits, append 4 zero bits to the input.
    • If the last group contains 4 bits, append 2 zero bits to the input.

In the first case, two pad characters (=) are appended to the Base64 output and in the second case, a single pad character (=) is appended.

Let’s see an example:

Input: @!
8-bit bytes: 01000000 00100001 
6-bit groups: 010000 000010 000100 
# (Appended with two zero bits at the end to form an integral no of 6-bit groups)
Decimal values: 16 2 4
Base64: Q C E
Final output: QCE= 
#(Appended with one pad character to account for the two zero bits added to the input.)

Learn more about Base64 encoding and decoding

We also have a tool to decode Base64 encoded data back to normal binary data. Check it out at https://www.base64decoder.io/.

To learn more about Base64 encoding, how it works, why it is required, and how to Base64 encode in different programming languages, check out the blog section.