How Base64 works
Base64 writes any bytes using 64 safe characters, so binary data can travel through systems built for text: e-mail, JSON, URLs, HTTP headers. Every 3 bytes (24 bits) become 4 characters of 6 bits each. When the data does not divide into groups of 3, the last group is shorter and = signs fill it up to 4 characters.
M a n 01001101 01100001 01101110 010011 010110 000101 101110 T W F u → TWFu
Text is turned into bytes first, and this page uses UTF-8 for that, the encoding nearly every system expects. That is why “é” becomes w6k= here; the browser's own btoa() function fails on such characters. The URL-safe variant from RFC 4648 swaps + and / for - and _, which need no escaping in addresses and file names, and often drops the padding. JSON Web Tokens use it.
When decoding, the page accepts both alphabets, missing padding, line breaks and a data: URL prefix. If a character is not Base64 it says which one and where. If the bytes are not valid UTF-8 text they are shown as hex, with a download that guesses the file type from its first bytes.
Example
The word “foobar” is 6 bytes, so it encodes to 8 characters with no padding: Zm9vYmFy. “fooba” is 5 bytes and gets one “=”: Zm9vYmE=. “f” alone becomes Zg==. These are the test values in RFC 4648.
Questions
Is Base64 encryption?
No. Base64 is an encoding: anyone can decode it without a key, exactly as this page does. It hides nothing. A password in a basic-auth header or a Kubernetes secret is only Base64-encoded, so protect it with HTTPS and access rules, not with the encoding.
Why is Base64 bigger than the original?
Every 3 bytes become 4 characters, so the result is about 33% larger, plus up to two = signs. Line breaks every 76 characters, as e-mail uses, add a little more. That is the price of using only safe text characters.
What is URL-safe Base64?
The variant defined in RFC 4648 section 5. It uses - and _ instead of + and /, which have special meanings in URLs and file names, and it often leaves out the = padding. JSON Web Tokens and many APIs use it. This page decodes both, and encodes either with the option above.
Why does decoding give strange characters?
Either the data is not text, such as an image, an archive or a key, or the text was encoded with another character set than UTF-8. This page shows binary data as hex and lets you download it as a file. If you see a few wrong letters in otherwise readable text, the source probably used Latin-1 or Windows-1252.
How do I decode Base64 on the command line?
On Linux: echo 'Zm9vYmFy' | base64 -d. On macOS: base64 -D, or base64 --decode on recent versions. To encode a file: base64 -w 0 file on Linux for one long line, base64 -i file on macOS. In PowerShell: [Convert]::FromBase64String('Zm9vYmFy').