Base64 encoder
This tool converts any UTF-8 text to Base64, with an optional URL-safe variant. It’s useful for embedding text in data URIs, building API payloads, constructing JWT-style segments, or any system that only accepts ASCII. Encoding runs entirely in your browser, so it’s safe for sensitive input.
How it works
The text is first turned into UTF-8 bytes with new TextEncoder().encode(text).
Those bytes are assembled into a binary string and passed to the browser’s native
btoa(), which produces standard Base64. Encoding via UTF-8 bytes first (rather
than calling btoa on the raw string) is what lets emoji and non-Latin
characters encode without errors. When URL-safe is on, the result is
post-processed: + becomes -, / becomes _, and trailing = padding is
stripped — the RFC 4648 URL-safe alphabet.
Example
| Input | Standard Base64 | URL-safe |
|---|---|---|
Hello | SGVsbG8= | SGVsbG8 |
a+b/c | YStiL2M= | YStiL2M |
café ☕ | Y2Fmw6kg4piV | Y2Fmw6kg4piV |
Base64 grows the data by about one third (3 bytes become 4 characters), so
Hello (5 bytes) becomes 8 characters before padding.
To reverse the process, use the Base64 decoder. Everything runs locally in your browser — nothing is uploaded.