Base64 Encode / Decode

Ready

Output
Input Length
Output Length

How Base64 Encoding Actually Works

Base64 converts arbitrary binary data into a string built from 64 printable ASCII characters (A–Z, a–z, 0–9, +, /), padded with = when needed. The algorithm groups the input's raw bytes into chunks of 3 bytes (24 bits) and re-slices those 24 bits into four 6-bit groups, each mapped to one character in the Base64 alphabet. Because 6-bit groups can only represent values 0–63, this is why exactly 64 symbols are needed. This is the standard defined in RFC 4648, and it's the same scheme used to embed images in CSS/HTML as data URIs, attach files in email (MIME), and encode binary tokens in JSON-based APIs.

Why "Just Use btoa()" Breaks on Non-English Text

The browser's native btoa() function only understands Latin1 (single-byte) characters — feed it an emoji, a curly quote, or a name with an accent, and it either throws an InvalidCharacterError or silently mangles the result. That's because Base64 is defined over raw bytes, and JavaScript strings are sequences of UTF-16 code units, not bytes. This calculator first converts your text to its actual UTF-8 byte representation before encoding, and reverses that step after decoding, so accented letters, symbols, and emoji round-trip correctly instead of just plain ASCII.

Encoding Is Not Encryption

A common misconception is that Base64 hides or protects data — it doesn't. It's purely a reversible representation format with no key and no security property; anyone can decode it instantly, which is exactly what the Decode mode above demonstrates. If you actually need to obscure or verify data, look at a dedicated tool such as a password generator for creating strong secrets, or a URL encode/decode calculator if what you actually need is to safely embed text inside a URL rather than transmit arbitrary binary data.

Frequently Asked Questions

Why does encoding some text with plain btoa() throw an error or give wrong results?

The browser's native btoa() function only supports Latin1 (single-byte) characters. Any text containing emoji, curly quotes, accented letters, or other non-Latin1 characters will either throw an InvalidCharacterError or produce corrupted output, because Base64 operates on raw bytes and JavaScript strings are UTF-16 code units. This tool works around that by converting your text to UTF-8 bytes first, so it correctly handles any Unicode text.

Is Base64 encoding a form of encryption or compression?

No. Base64 is neither encryption nor compression — it is a reversible representation format with no secret key, and it actually makes data about 33% larger, not smaller. Anyone can decode Base64 text instantly with no password required, so it should never be used to protect sensitive information; use it only when you need to safely represent binary data as plain text (e.g. embedding images or files in text-based formats like JSON, XML, or data URIs).