1. Home
  2. Tools
  3. Base 64 Encoder

Base 64 Encoder

Do you find this helpful?

Use this online free Base64 Encoder tool that converts any text, local files, or remote files (URL) to Base64. Just type or past any data in the input textarea above, and the tool will convert it to Base64 encoded format.

Base64 is an encoding algorithm that allows converting any characters into an alphabet which consists of Latin letters, digits, plus, and slash. Due to this algorithm, even Chinese characters, emojis, and images can be converted into a “readable” string.

In computer science, Base64 is a group of binary-to-text encoding schemes that represent binary data in an ASCII string format by translating it into a radix-64 representation. The term Base64 originates from a specific MIME content transfer encoding. Each Base64 digit represents exactly 6 bits of data. Three 8-bit bytes (i.e., a total of 24 bits) can, therefore, be represented by four 6-bit Base64 digits.

Common to all binary-to-text encoding schemes, Base64 is designed to carry data stored in binary formats across channels that only reliably support text content. Base64 is particularly prevalent on the World Wide Web where its uses include the ability to embed image files or other binary assets inside textual assets such as HTML and CSS files. (Wikipedia)

The set of 64 characters chosen to represent the 64 place-values for the base varies between implementations. The general strategy is to choose 64 characters that are common to most encodings and that are also printable. This combination leaves the data unlikely to be modified in transit through information systems, such as email, that were traditionally not 8-bit clean. For example, MIME's Base64 implementation uses A–Z, a–z, and 0–9 for the first 62 values. Other variations share this property but differ in the symbols chosen for the last two values; an example is UTF-7.

Initially, the algorithm was named “printable encoding” and only in June 1992, RFC 1341 defines it as “Base64”. The 64 characters represent the 64 place-values for the base varies between implementations.

The history of the Base64 algorithm started when, in the past, engineers argued over how many bits should be in a byte. Some decades ago, seven-bit, six-bit, and three-bit bytes were used. But when the eight-bit byte was approved as standard many systems used old standards and did not support the new one. Some problems occurred. For example, a mail server may discard the eighth bit when sending emails or they could only send text, but not images, videos, archives, etc.. So a new algorithm was developed to solve this problem - Base64.

Base64 is most commonly used to encode binary data such as images, or sound files for embedding into HTML, CSS, EML, and other text documents. In addition, Base64 is used to encode data that may be unsupported or damaged during transfer, storage, or output.

Base64 encoding comes to the rescue when media is transmitted in raw binary format to text-based systems.

Since text-based systems like email interpret binary data as a wide range of characters, including special command characters, much of the binary data that is transmitted to transfer media is misinterpreted by those systems and lost or corrupted in the transmission process.

One method of encoding this kind of binary data in a way that avoids such transmission problems is to send it as plain ASCII text in Base64 encoded format. This is one of the techniques employed by the MIME standard to send data other than plain text.

Base64 Encoding Logic

Base64 encoding breaks binary data into 6-bit segments of 3 full bytes representing those as printable characters in ASCII standard. It does that in essentially two steps.

The first step is to break the binary string down into 6-bit blocks. Base64 only uses 6 bits (corresponding to 2^6 = 64 characters) to ensure encoded data is printable and humanly readable. None of the special characters available in ASCII are used.

The 64 characters are 10 digits, 26 lowercase characters, 26 uppercase characters as well as the Plus sign (+) and the Forward Slash (/). There is also a 65th character known as a pad, which is the Equal sign (=). This character is used when the last segment of binary data does not contain a full 6 bits.