Understanding Base64 Encoding
How binary data gets represented as plain text, and why.
Base64 is a way of taking binary data and representing it using only a small set of text characters. It shows up all over computing, usually in places that were built to move text around and don't handle raw binary well. Here's how it works and where you'll run into it. There's a Base64 tool on this site if you want to try encoding or decoding something.
What it does
Computers store data as binary, which is just sequences of bytes, and plenty of those byte values don't map to any printable text character. The trouble is that some systems, including certain email and web protocols, were designed around text in the first place and can't be trusted to carry arbitrary binary safely. Base64 gets around this by translating that binary into a string of characters drawn from a set of 64 printable ones, so the data can travel through text-based systems without getting mangled.
How it works
The mechanics are simple once you see them. Base64 takes the input three bytes at a time, which is 24 bits, and re-slices those 24 bits into four groups of six. Each six-bit group maps to one of the 64 characters: the uppercase letters, the lowercase letters, the digits, and two extra symbols. When the input doesn't divide evenly into three-byte groups, padding characters, usually the equals sign, get tacked on to signal the original length.
Size increase
There's a cost to all this. Since three bytes of input become four characters of output, encoded data ends up roughly one-third larger than the original. That growth is the price you pay for being able to express binary as text. So Base64 is something you reach for when you need text compatibility, not when you're trying to make data smaller. If anything, it does the opposite.
Common uses
You'll find Base64 in a handful of familiar places. Email attachments are often Base64-encoded so binary files can ride along inside text-based messages. Web pages sometimes embed small images right in the markup using Base64 in a data URL, which saves a separate request for the image. It also turns up whenever binary data needs to sit inside a text format like JSON or XML, and inside certain tokens and configuration files.
A note on security
This is worth being clear about: Base64 is encoding, not encryption. It doesn't protect or hide anything, since anyone can decode Base64 back to the original with tools that are a quick search away. Don't lean on it to keep something confidential. Its whole job is to put data in a text-friendly form, not to secure it.
Summary
In short, Base64 encodes binary as text using a set of 64 characters, letting that data move through and live in text-based systems. It grows the data by about a third and offers no security of its own. You'll see it most in email, web pages, and text-based data formats.