What is Base64 encoding?

Base64 is a method of encoding data as ASCII text. It is often used when sending binary data over email because email systems only support text data.

Encoding data in Base64

To encode data in base64, the data is first converted into bytes and then divided into blocks of 6 bits. Each block is then represented by a printable ASCII character from a set of 64 characters. These characters include the uppercase and lowercase letters, the digits 0 through 9, and some punctuation symbols.

There are some limitations to using base64 encoding for email. One limitation is that base64 encoded data is about 33% larger than the original data so it may increase the size of the email message. Another limitation is that some email servers and clients may not support base64 encoding, which could cause problems when sending or receiving emails.


Original data: This is some text data. Size: 22 bytes
Base64 encoded data: VGhpcyBpcyBzb21lIHRleHQgZGF0YS4= Size: 29 bytes

As you can see, the base64 encoded data is about 33% larger than the original data. This size increase can be a problem if you send large attachments over email because it can cause the email message to exceed the size limits set by the email server or client.

Additionally, if an email server or client does not support base64 encoding, it may not be able to handle email messages that contain base64 encoded data correctly. This could cause the email message to be displayed improperly or to be rejected by the server.