Base64 is not encryption. It is not compression. Here is what it actually does.
Base64 is one of the most misused encodings on the web. It does not encrypt anything. It does not make text “safer” in any cryptographic sense. It makes payloads larger, not smaller. It exists for exactly one job: turning arbitrary bytes that are not printable ASCII into bytes that are. Knowing the actual job description spares you a lot of bad architecture.
What Base64 actually does
Three bytes of input (24 bits) are split into four 6-bit groups, each mapped to a printable character from a 64-character alphabet (A–Z, a–z, 0–9, +, /), with = as padding. The output is always a multiple of four characters. Every three input bytes become four output bytes — a constant 33% inflation, no exceptions. There is no information loss; the operation is fully reversible by anyone with no key.
When to use it
Email attachments (the original use case; defined in RFC 2045 MIME) where SMTP is a 7-bit text protocol. Small images embedded in HTML or CSS via data: URIs to skip a network round-trip on first paint. Binary fields in JSON (a JWT signature, a TLS certificate, a file upload). Transport over channels that strip the 8th bit or normalise whitespace.
When NOT to use it
Storing passwords: Base64 is reversible by definition. Use bcrypt, scrypt or Argon2. “Encrypting” config files: if you Base64-encode a secret to “obfuscate” it, anyone with the file has the secret in two seconds. Use real encryption (libsodium, age, sops). Inline Base64 for large assets: a 100 kB image becomes 133 kB of Base64 plus a 1–3% gzip overhead, and it cannot be cached separately from the HTML — defeats the browser’s entire caching strategy. Inline only the truly small (under ~4 kB).
URL-safe Base64
+ and / have special meaning in URLs and need to be percent-encoded, which defeats the point of using Base64 in a URL. The URL-safe variant (RFC 4648 §5) replaces them with - and _ respectively, so the result survives URL encoding without further quoting. Padding (=) is usually dropped in this variant. JWTs use URL-safe Base64.
Base64 in JWT — readability is not security
JWTs are Base64url-encoded, which is why anyone can paste a token into this decoder and see the payload. The signature is what matters — it proves the server issued and signed the token. The payload being “encoded” in Base64 is purely transport-friendliness; it is not even slightly hidden. Do not put secrets in JWT payloads.
Takeaway: Base64 transports arbitrary bytes through text-only channels. That is the entire job. If you see Base64 protecting “sensitive” data without a separate encryption layer, you are looking at security theatre. The encoder/decoder on this page handles both standard and URL-safe variants and accepts missing padding. Use it for debugging; use real crypto for real secrets.
Sources: RFC 4648 (Base16, Base32, Base64) · RFC 2045 (MIME) · MDN data: URIs.