Dev Hub Solutions

Product studio

Get in touch

Base64 encode Emoji & Unicode

Base64-encode a string containing emoji or non-Latin characters.

Example

Input

๐Ÿš€ Hello

Base64 output

8J+agCBIZWxsbw==

The gotcha

The naive approach โ€” `btoa("๐Ÿš€ Hello")` in browser JavaScript โ€” throws `InvalidCharacterError`. `btoa` only handles Latin-1 (byte values 0โ€“255). Real Unicode characters use multiple bytes in UTF-8, so you need to UTF-8 encode to bytes first, then Base64-encode the bytes.

When to use this

Anytime you're encoding strings that might contain emoji, Chinese, Arabic, accented characters, or any character outside the basic Latin range. Decoding must reverse the same steps โ€” Base64-decode to bytes, then `TextDecoder` from bytes to string.

Open the encoder