2026-08-26
What Base64 encoding actually does
Base64 is a way to write bytes using 64 ASCII characters. It is not encryption, hashing, or compression. Anyone who sees the output can decode it.
Why it exists
Many protocols were built for printable text. Binary data — or UTF-8 that includes bytes above 127 — needs a safe alphabet. Base64 maps every three bytes to four characters from A–Z, a–z, 0–9, +, and /. Padding with = fills out the last block.
Ada Lovelace → QWRhIExvdmVsYWNl
UTF-8 matters
Browser btoa() treats each character as a single Latin-1 byte. Passing “✓” straight in throws or corrupts. The right sequence is: UTF-8 encode the string, then Base64-encode those bytes. Alphzen’s Base64 Encoder does that.
URL-safe Base64
JWTs and some query strings use - and _ instead of + and /, and they often drop padding. That is still Base64, just a different alphabet (RFC 4648 §5). Decoding should accept both.