What is Base64 encoding?
Short answer
Base64 is a way to represent binary data using 64 printable ASCII characters. It lets binary content travel through channels designed for text, such as URLs, JSON, and email. It is encoding for safe transport, not encryption for security.
Why Base64 exists
Many systems were built to handle text, not raw bytes. Email, URLs, and JSON can corrupt arbitrary binary data. Base64 solves this by mapping every 3 bytes of input onto 4 characters from a safe alphabet: A-Z, a-z, 0-9, plus + and /, with = used for padding.
"Hello" -> "SGVsbG8="The size cost
Because 3 bytes become 4 characters, Base64 output is about 33 percent larger than the original. That is the trade-off for safe transport through text-only channels.
Where you see it
- Data URIs that embed images directly in HTML or CSS
- Email attachments, via MIME
- The header and payload of a JWT, which use a URL-safe Base64 variant
- Binary fields passed inside JSON
The URL-safe variant (RFC 4648) replaces + and / with - and _ so the text can sit in a URL without escaping.