Base64 Encoder and Decoder

Online Free Base64 Encoder and Decoder tool.Our tool Encodes or Decodes a string using Base64 and make sure it aligned with the Base64 Data Encodings specification (RFC 4648).

Base64 Encoding Explained

Why Base64 Encoding / Decoding ?

There are several reasons why you might need to use Base64 encoding:

  • To attach binary data to an email message.
  • To embed binary data in a web page or other text-based document.
  • Data storage in text-based formats: To store binary data in a configuration file.
  • Data transmission: To transmit binary data over a network that only supports ASCII characters.
  • Encryption and hashing: To obfuscate binary data, such as passwords or API keys.
  • To store binary data in a database that only supports text fields.
  • To transfer binary data over a protocol that only supports text, such as HTTP.

How does Base64 encoding work?

Base64 encoding works by converting binary data into a text format using a 64-character alphabet. The alphabet consists of the characters A-Z, a-z, 0-9, +, and /. Each 3-byte block of binary data is converted into 4 characters from the Base64 alphabet. The last block of binary data may be padded with one or two extra bytes, depending on its length.

  • Dividing: Base64 encoding operates on 8-bit units, so the binary data is divided into groups of three bytes (24 bits).
  • Converting: Converting the three bytes into a 24-bit binary number: Each group of three bytes is combined into a 24-bit binary number.
  • Splitting: Splitting the 24-bit binary number into four 6-bit units: The 24-bit binary number is split into four 6-bit units. These 6-bit units form the indices for selecting characters from the Base64 character set.
  • Mapping: Each 6-bit unit is treated as an index value, and the corresponding character from the Base64 character set is selected. The Base64 character set consists of 64 characters, typically comprising uppercase letters (A-Z), lowercase letters (a-z), numbers (0-9), and two additional characters, such as '+' and '/'. These characters are used to represent the binary data.

The following table shows the mapping from binary data to Base64 characters:

Byte Base64 Character
0000 A
0001 B
0010 C
0011 D
0100 E
0101 F
0110 G
0111 H
1000 I
1001 J
1010 K
1011 L
1100 M
1101 N
1110 O
1111 P

Some additional details about Base64 encoding:

  • Base64 encoding is a lossless encoding, which means that the original binary data can be perfectly reconstructed from the encoded data.
  • Base64 encoding increases the size of the data by 33%. This is because each group of 3 bytes is converted into 4 characters of text.
  • Base64 encoding is not secure