You've probably seen a long string of letters, numbers, and a few +, /, and = characters somewhere in an API response, an email attachment, or a data: URL in a stylesheet. That's almost certainly Base64 — one of the quietest, most widely used pieces of internet infrastructure, and one that's frequently misunderstood as a form of security.

The problem Base64 solves

Lots of systems were designed to handle text, not arbitrary binary data. Email, in particular, was built around 7-bit ASCII text decades ago, and plenty of modern systems (JSON strings, URLs, XML) still expect plain, printable characters. But images, PDFs, and other binary files are just raw bytes, including many byte values that don't correspond to printable characters at all, and some of which would be actively misinterpreted by text-oriented systems (like a byte that happens to look like a line-ending or control character). Base64 solves this by re-encoding any binary data into a string made up entirely of 64 safe, printable characters — letters, digits, +, and / — that can pass through text-only systems without corruption.

How it works, conceptually

Base64 takes your data 3 bytes (24 bits) at a time, and repackages those 24 bits into 4 characters of 6 bits each, since 6 bits is exactly enough to represent 64 distinct values (26 = 64) — hence the name. Each 6-bit chunk maps to one character from a fixed alphabet: A–Z, a–z, 0–9, plus two more symbols (typically + and /) to reach 64 total. If the input isn't a clean multiple of 3 bytes, one or two = padding characters get added at the end to keep the output length consistent.

The practical result: Base64-encoded data is always about 33% larger than the original binary. That's the trade-off for making it safely text-representable.

A concrete example

The text "Hi!" encodes to:

SGkh

Three characters of input became four characters of output — consistent with the 3-bytes-in, 4-characters-out pattern. Decoding reverses the process exactly, recovering the original three bytes.

Where you actually run into Base64

The one thing everyone eventually gets wrong: Base64 is not encryption

This deserves to be said plainly: Base64 provides zero confidentiality. It's a reversible encoding scheme with a completely public, standardized algorithm — there's no secret key involved anywhere in the process. Anyone can decode a Base64 string back to its original form in one line of code, in any language, instantly. If you see Base64-encoded data and think "that's obfuscated, so it's probably safe to expose," that assumption is wrong. Treat Base64-encoded sensitive data exactly as if it were sent in plain text, because functionally, it is.

Base64 vs. Base64URL

Standard Base64 uses + and / as two of its 64 characters. Both of those have special meaning inside a URL (+ can mean a space, / separates path segments), so using standard Base64 directly inside a URL can break things. Base64URL is a small variant that swaps + for - and / for _, and typically drops the trailing = padding, making the result safe to use directly inside a URL or filename without further escaping. This is the variant JWTs use.

A quick way to sanity-check what you're looking at

If a string is made up only of letters, digits, and possibly +, /, or = at the end (or -, _ for the URL-safe variant), and its length is a multiple of 4, there's a good chance it's Base64. Decoding it takes a fraction of a second and often immediately clarifies what you're actually looking at — readable text, a small image, or structured binary data.

Frequently Asked Questions

No. Base64 is an encoding scheme, fully reversible by anyone with no key required. It changes how data is represented, not whether it's readable — encryption requires a secret key and is specifically designed to prevent reading without one.
Those are padding characters, added when the original data length isn't an exact multiple of 3 bytes. They keep the encoded output at a consistent, decodable length; one or two = signs may appear depending on how much padding was needed.
Because it repackages every 3 bytes of input into 4 characters of output, Base64 encoding increases size by roughly 33%. That overhead is the trade-off for making binary data safely representable as plain text.
They use the same core scheme, but Base64URL replaces the two characters that have special meaning in URLs (+ and /) with URL-safe alternatives (- and _), and usually omits padding — making it safe to use directly inside a URL or filename.