How Base64 works, one bit at a time
Base64 takes your bytes three at a time — 24 bits — and cuts them into four 6-bit pieces. Six bits can count from 0 to 63, and each number picks one character from a 64-letter alphabet: A–Z, a–z, 0–9, + and /. That’s the whole trick, and why the output is always 4/3 the size of the input.
Hi!
7210533
010010000110100100100001
S18G6k36h33
“Hi!” → SGkh · 3 bytes in, 4 characters out.
When the last group has only one or two bytes, zeros fill the missing bits and = signs stand in for the empty 6-bit slots — that’s the padding you see at the end of so many Base64 strings. If you like learning this way, ahaboo has narrated interactive explainers on how everyday things really work, one “aha” at a time.
What Base64 is for
Base64 turns arbitrary bytes into 64 safe ASCII characters so binary data can travel through text-only channels: email attachments (MIME), data URIs in CSS and HTML, JSON fields, HTTP Basic auth headers and JWTs. It is encoding, not encryption — anyone can decode it.
Standard vs. URL-safe
Standard Base64 (RFC 4648) uses + and /, which have special meanings in URLs. The URL-safe alphabet swaps them for - and _ and usually drops the = padding. The decoder accepts both automatically.
Why the output is a third bigger
Every 3 bytes become 4 characters, so Base64 is about 33% larger than the original. Step through the explainer below to see exactly how.
Questions
Why do I get “binary data (not UTF-8 text)”?
The Base64 holds a file such as an image or PDF, not text. Use the download button to save the decoded bytes; images are previewed.
Does it handle emoji and accented characters?
Yes. Text is encoded as UTF-8 before Base64, which is what virtually every modern system expects.
What does the = at the end mean?
Padding. When the input length is not a multiple of 3 bytes, one or two = signs fill the last 4-character group.