"category": "dev-utility",
Base64 Encoder
"tldr": Paste any text and get Base64 - UTF-8 safe, so unicode and emoji encode correctly, unlike naive btoa().
Encode any text as Base64 with correct UTF-8 handling: the text is converted to UTF-8 bytes first, then Base64-encoded - so accents, CJK characters, and emoji all round-trip correctly. (Naive JavaScript btoa() throws or corrupts on exactly those characters.)
Base64 turns arbitrary data into a safe ASCII token for channels that cannot carry it raw: HTTP Basic auth headers, environment variables, XML/JSON string fields, and data URIs. Remember what it is not: encryption. Anyone can decode it.
How to Base64-encode text
- 1Paste your text - any unicode is fine.
- 2It is encoded to UTF-8 bytes, then to standard Base64 with padding.
- 3Copy the result into your header, config, or payload.
- 4For JSON documents specifically, our JSON to Base64 tool validates the JSON first.
Convert Text to Base64 in code
const bytes = new TextEncoder().encode(text);
const b64 = btoa(String.fromCharCode(...bytes));import base64
base64.b64encode("pässword-🎉".encode()).decode()Frequently asked questions
Why does btoa() fail on my string when this tool works?
btoa() only accepts characters up to code point 255 - anything beyond (é is fine, 中 or 🎉 are not) throws InvalidCharacterError. The fix, which this tool implements, is TextEncoder first: encode to UTF-8 bytes, then Base64 the bytes.
Is Base64 encryption or hashing?
Neither - it is a reversible encoding, decodable by anyone in one function call. Never use it to protect secrets. If you need confidentiality, encrypt; if you need integrity, hash or sign - Base64 is only the transport wrapper.
What is Base64url and when do I need it?
A URL-safe variant: + becomes -, / becomes _, padding is dropped. JWTs and URL parameters use it because + and / have meanings in URLs. Apply those three substitutions to this output, or use your language's urlsafe variant.
Last updated:
You might also need
Free and in-browser, like everything on JSON Console. Browse all tools →