Many old systems were designed to handle text only. Email is the classic example: when the SMTP protocol was invented in the 1980s, it expected 7-bit ASCII. Bytes like 0x80-0xFF would be silently corrupted by some servers along the way. So when you attach a photo to an email, your mail client encodes the photo as Base64 text, which survives the journey intact.
The same problem reappears constantly: JSON cannot directly hold binary data, URLs cannot contain arbitrary bytes, JWT tokens have to fit in an HTTP header, and so on. Base64 is the duct tape that holds the internet together.
The trick is simple. Binary data is made of bytes (8 bits each). Base64 regroups those bits into chunks of 6, which can each represent 64 different values - exactly the size of the Base64 alphabet. Three bytes (24 bits) become four Base64 characters (24 bits).
That math is why Base64 makes data bigger. A 100 KB image turns into roughly 133 KB of Base64 text. The exact overhead is 33% plus a small amount for padding.
The padding is the trailing = sign you sometimes see. If the input is not a multiple of 3 bytes, Base64 pads with = to keep the output length a multiple of 4. Some applications skip the padding entirely; that is also valid Base64 as long as the decoder agrees.
| Variant | Alphabet | Where you see it |
|---|---|---|
| Standard | A-Z, a-z, 0-9, +, / | Email attachments (MIME), most APIs, certificates. |
| URL-safe | A-Z, a-z, 0-9, -, _ | JWT, URL parameters, file names. Replaces the two characters that would otherwise need URL-encoding. |
| Base32, Base58, Base85 | Different alphabets | Less common. Base58 is used by Bitcoin addresses; Base85 by older PostScript. |
header.payload.signature) are Base64-URL-encoded.data:image/png;base64,iVBORw0... strings you see in HTML and CSS.-----BEGIN ...----- and -----END ...-----.Authorization: Basic ... header.
Encode and decode Base64, URL, hex, and more on iPhone, iPad, and Mac. Plus JSON, Markdown, regex, and AI text actions. · iPhone, iPad & Mac