Base64 Encode/Decode

Encode and decode text to Base64 instantly.


                    

What is Base64 and when should you use it?

Base64 is a binary-to-text encoding scheme that converts binary data into an ASCII text string using 64 different characters (A-Z, a-z, 0-9, + and /). It was designed to ensure that data can be safely transmitted through media that only process text, such as email protocols (SMTP), URLs, or HTML attributes.

Base64 encoding increases the size of the original data by approximately 33%, since each group of 3 bytes is represented with 4 ASCII characters. Despite this overhead, it remains indispensable in scenarios where the integrity of binary data during transmission is a priority.

Practical use cases

Images in CSS/HTML: Embed small images (icons, logos) directly in stylesheets or HTML using data URIs, eliminating additional HTTP requests and improving load performance.

HTTP Basic Authentication: User credentials are encoded in Base64 before being sent in the Authorization header. While it doesn't provide encryption, it standardizes the credential format.

Email attachments: Binary files (PDFs, images, documents) are encoded in Base64 for transmission through the SMTP protocol, which originally only supported ASCII text.

Certificate storage: SSL/TLS certificates and public keys are frequently distributed in PEM format, which is essentially Base64 with specific headers.

Frequently asked questions

Is Base64 encryption?

No. Base64 is an encoding, not encryption. Anyone can decode Base64 without needing a key. Don't use Base64 to protect sensitive information; for that you need encryption algorithms like AES or RSA.

Why does my encoded text end with "=="?

The "=" characters at the end are padding. Base64 processes data in blocks of 3 bytes that produce 4 characters. If the last block has fewer than 3 bytes, "=" characters are added to complete the output block.

What is URL-safe Base64?

It's a variant that replaces "+" with "-" and "/" with "_" so the result is safe for use in URLs and filenames. It may also omit the "=" padding. It's frequently used in JWTs and access tokens.

How much does the size increase when encoding to Base64?

Base64 increases the original size by approximately 33%. For example, a 1MB file becomes approximately 1.33MB. This is because every 3 bytes of input produce 4 bytes of output.

Base64 character table

The standard Base64 alphabet uses 64 characters: uppercase letters (A-Z, indices 0-25), lowercase letters (a-z, indices 26-51), digits (0-9, indices 52-61), and the symbols "+" (index 62) and "/" (index 63). The "=" character is used exclusively as padding.