You have probably met Base64 in the wild: an API token, a data URI in an image tag, a long string pasted into a config file, or an email attachment. It looks like random letters, numbers, + and /, often ending in =.
Base64 is not magic. It is a way to represent any bytes as plain, safe text characters so they survive places that only handle text — URLs, JSON, emails, config files. Every 3 bytes become 4 characters, which is why encoded output is about 33% larger than the input.
The trap: emoji and non-English text break naive encoding
In the browser, the classic functions are btoa() and atob(). They only handle Latin-1 characters. Feed them an emoji or Hindi, Arabic, Chinese text and they throw an error or corrupt the result.
The fix is to encode the text as UTF-8 first, then Base64-encode those bytes. A Unicode-safe way in modern JavaScript:
// Encode, Unicode-safe
const bytes = new TextEncoder().encode("Hello 🌍");
const binary = String.fromCharCode(...bytes);
const encoded = btoa(binary); // SGVsbG8g8J+MjQ=
// Decode, Unicode-safe
const decodedBytes = Uint8Array.from(atob(encoded), c => c.charCodeAt(0));
const decoded = new TextDecoder().decode(decodedBytes); // Hello 🌍
If you just need the answer once, you do not need to write this code or install anything.
Encode or decode in seconds, without installing anything
- Paste your text and click Encode, or paste a Base64 string and click Decode.
- Invalid Base64 shows a clear error instead of garbage output — that matters when you are debugging a token and cannot tell whether the string itself is broken.
- Copy the result with one click.
Try it here: https://bulktextkit.gt.tc/tools/base64-encoder-decoder.php?utm_source=devto
It runs entirely in your browser, so the text you paste never leaves your device — useful exactly when the string you are decoding is a real token.
One thing Base64 is not: encryption
Anyone can decode a Base64 string instantly. It hides nothing. Never use it to "protect" a password or secret — use real encryption for that. Base64 is for transport and compatibility, not security.
BulkTextKit Pro is a $19 one-time payment that adds bulk processing for up to 50 texts at once, saved presets, and CSV export — the 15 free tools stay free.
Top comments (0)