Base64 Encoder/Decoder

Convert text or files to and from Base64, safely handling Unicode.

UTF-8 safe — multibyte characters and emoji round-trip correctly.
Advertisement

About Base64 Encoder/Decoder

Encode text or files to Base64 or decode Base64 back to text, with correct UTF-8 handling so emoji and multibyte characters survive the round trip. Invalid Base64 input is caught and explained instead of silently corrupting output.

Base64 turns arbitrary bytes into a string of only 64 printable characters (A-Z, a-z, 0-9, + and /), which is why it shows up everywhere bytes need to survive being embedded in text: email attachments, data: URLs, JWT segments, and Basic Auth headers.

A common bug when encoding text (rather than raw files) is treating a string as if every character were one byte. That silently breaks on emoji and most non-English text, because those characters take multiple bytes in UTF-8. This tool encodes through TextEncoder/TextDecoder rather than the browser's raw btoa/atob, so accented characters, CJK text, and emoji all round-trip correctly.

For file input, we read the file's raw bytes directly and Base64-encode them without ever assuming they're valid text — appropriate for images, PDFs, or any binary format, not just plain text.

Frequently asked questions

Why does decoding sometimes fail with 'invalid Base64'?
Base64 has a strict alphabet and padding rules: it only uses A-Z, a-z, 0-9, + and /, and its length (ignoring whitespace) must be a multiple of 4, padded with = at the end if needed. If you paste a URL-safe Base64 variant (which uses - and _ instead of + and /), a truncated string, or plain text that isn't Base64 at all, decoding will fail with an explanation rather than silently returning garbage.
Will this break on emoji or non-English text?
No — encoding goes through UTF-8 byte encoding first, so multibyte characters like emoji, accented letters, and CJK text encode and decode correctly. This is a common failure point in quick btoa()/atob() based tools that this one specifically avoids.
Can I Base64-encode a whole file, not just text?
Yes — switch to Encode mode and use "Encode a file instead" to pick any file from your device. It's read as raw bytes in your browser and encoded directly; the file itself is never uploaded anywhere.