The problem Base64 solves
Lots of systems on the internet — older email protocols, many text-based APIs, URLs — were built to reliably carry plain, printable text but not arbitrary binary data. Binary data (like an image file) contains byte values that can be misinterpreted, corrupted, or outright rejected by systems expecting text. Base64 exists to bridge that gap: it re-encodes any data, binary or not, into a string made up of only 64 safe, printable ASCII characters (A–Z, a–z, 0–9, plus + and /), which can pass through virtually any text-oriented system unmodified.
What it costs you: about 33% more size
Base64 isn't free — representing data in a smaller, safer alphabet of characters takes more characters to say the same thing, specifically about 33% more. Every 3 bytes of original data become 4 characters of Base64 text, which is the direct, unavoidable cost of restricting the output to that safe 64-character set. This matters when deciding whether to Base64-encode something size-sensitive, like embedding an image directly in HTML or CSS as a data URL.
Base64 is not encryption
This is the single most important thing to understand about Base64, and the most common misconception: it provides zero confidentiality. Anyone — no password, no key, nothing — can decode a Base64 string straight back to its original content instantly. It looks unreadable at a glance, which is exactly why people sometimes mistake it for a security measure, but it's purely a format conversion. If you need to actually protect data, that's what real encryption is for; Base64 solves a compatibility problem, not a privacy one.
Try encoding and decoding
Where you'll actually run into it
HTTP Basic Authentication headers Base64-encode a username:password pair before sending it (again — not encryption, just a required format, which is exactly why Basic Auth should only ever be used over HTTPS). Data URLs let you embed a small image directly inside HTML or CSS as Base64 text instead of a separate file request, trading a larger inline size for one fewer network round-trip. Base64 is also the standard way to safely embed binary data — like a cryptographic key or a small file — inside a text-based format like JSON or XML, which have no native way to represent raw binary bytes.
How it actually works, briefly
Base64 takes input data 3 bytes (24 bits) at a time, splits those 24 bits into four 6-bit chunks, and maps each 6-bit chunk to one character from the 64-character alphabet — 6 bits is exactly enough to represent 64 distinct values, which is where the name comes from. When the input isn't a clean multiple of 3 bytes, one or two = padding characters are appended at the end to keep the output length a multiple of 4, which is why you'll often see a Base64 string ending in one or two equals signs.