Base64 Encode UTF-8 Text and Emoji

Encode Unicode text, accents and emoji to Base64 correctly. Avoid the btoa "Invalid character" error by encoding as UTF-8 first.

Part of the free Base64 Encoder. Runs in your browser — nothing is uploaded.

Base64 Encode UTF-8 Text and Emoji

JavaScript's btoa() throws on characters outside Latin-1, and many online encoders corrupt them. This encoder converts text to UTF-8 bytes first, so every character, including emoji, round-trips safely.

Worked example: Accents and an emoji

Text

Café ☕ naïve

Base64

Q2Fmw6kg4piVIG5hw692ZQ==

Practical tip

In JavaScript, encode with btoa(String.fromCharCode(...new TextEncoder().encode(text))) or use Buffer.from(text, "utf8").toString("base64") in Node.

How to use this Base64 Encoder

  1. 1Use the live tool above — it runs entirely in your browser and never uploads your data.
  2. 2Paste the sample from the worked example, or use your own input.
  3. 3Copy the result, then adapt the same steps in your editor, script, or pipeline.

Base64 Encode UTF-8 Text and Emoji FAQs

Why does btoa fail on emoji?

btoa only accepts characters with code points up to 255. Emoji exceed that, so you must convert to UTF-8 bytes first.

Do I get the same result in Python and Node?

Yes, as long as both encode text as UTF-8 before Base64. The Base64 algorithm itself is identical everywhere.

More Base64 Encoder pages

Open the full Base64 Encoder tool →