Base64 Encoder & Decoder
Encode text to Base64 or decode Base64 back to text instantly in your browser. Unicode-safe. Nothing is uploaded.
Use this free Base64 encoder and decoder to convert text to Base64 or Base64 back to text instantly. It handles full Unicode — emoji, accents, and CJK characters all round-trip correctly — and supports the URL-safe (Base64URL) variant used in JWTs and URL parameters.
How to use it
No account, no upload — it all happens on your device.
How Base64 actually works
Three bytes in, four characters out.
Base64 takes raw bytes in groups of three (24 bits) and rewrites each group as four 6-bit pieces, looked up in a 64-character alphabet (A–Z a–z 0–9 + /). 64 = 2⁶, which is why six bits map cleanly to one character. The output is always 33% larger than the input — three bytes become four ASCII chars.
If the input length isn't a multiple of three, the last group is padded with one or two = characters. That padding is what tells a decoder where the message ends.
Worked examples
Plain text in, Base64 out.
| Input | Base64 | URL-safe Base64 |
|---|---|---|
| A | QQ== | |
| AB | QUI= | QUI |
| ABC | QUJD | QUJD |
| hello | aGVsbG8= | aGVsbG8 |
| café | Y2Fmw6k= | Y2Fmw6k |
| 🎉 | 8J+OiQ== | 8J-OiQ |
Notice the URL-safe column drops the padding and swaps any + / / with - / _. Otherwise it's the same encoding.
Where it shows up in real apps
Some places use Base64 you might not have noticed.
- Data URIs for inline images and fonts:
data:image/png;base64,iVBORw0KG.... - HTTP Basic Auth:
Authorization: Basic dXNlcjpwYXNzis the Base64 ofuser:pass. - JWT: each of the three dot-separated parts is Base64URL-encoded JSON.
- Email (MIME) attachments are wrapped in Base64 to survive plain-text transports.
- SSH keys:
ssh-rsa AAAAB3...— the second field is Base64 of the binary key. - API payloads: when JSON has to carry binary blobs (images, PDFs), they're usually Base64.
Common confusions
- Base64 is not encryption.It is encoding — anyone who has the string can decode it. Never use it to "hide" a secret.
- It doesn't compress. The output is always ~33% larger than the input. If you need smaller, use gzip before encoding.
- Whitespace is sometimes legal. MIME allows line wraps inside Base64 — most decoders ignore newlines and spaces. This decoder strips them automatically.
- Older encoders break on Unicode. The JavaScript built-in
btoa()throws on non-Latin1 characters; this tool wraps it with a TextEncoder so emoji and CJK work correctly.