Base64 encoding

Base64 encoding

The concept of Base64 encoding entails using US-ASCII (non-accented) characters to encode any sort of data in 8-bit form.

Email protocols were originally designed to send messages in plain text only. But as email systems vary greatly, transferring binary data often ends up changing the message's content, rendering the original document unreadable.

Base64 format, widely used in sending and receiving email, can transmit any kind of binary document (like an application, a video, or an audio file) as an attachment to an email, by encoding it in the form of basic characters.

Base64 encoding is responsible for an overall 33% increase in the volume of all encoded data.

Concept of Base64 encoding

The concept of Base64 encoding involves using 4 printable characters (in US-ASCII format) to encode any 3 bytes (3*8 bits = 24 bits).

Base64 encoding uses an alphabet of 64 printable characters to represent 6 bits of data. This alphabet's 64 symbols have been chosen for being universally readable, and for having no special meaning in the main email protocols (in particular SMTP).


Reading the binary data from left to right, groups of 24 bits are created by concatenating blocks of three bytes of data each. Each 24-bit group is then divided into 4 groups of 6 bits, with each one corresponding to 4 characters of the Base64 alphabet.

Base64 encoding is used for data which forms a multiple of 24 bits. If the amount of data to be encoded is not a multiple of 24 bits, the resulting Base64 string must end with between 0 to 3 equal signs ("=") in order to reach a multiple of 24. This 65th character may only be used at the end of the encoded data.

To ensure compatibility with all email systems, Base64 data is formatted with carriage returns, so that no line is longer than 76 characters.

Ask a question
CCM is a leading international tech website. Our content is written in collaboration with IT experts, under the direction of Jean-François Pillou, founder of CCM reaches more than 50 million unique visitors per month and is available in 11 languages.


This document, titled « Base64 encoding », is available under the Creative Commons license. Any copy, reuse, or modification of the content should be sufficiently credited to CCM (