Skip to main content
Developer ToolsAugust 24, 2026 · 2 min read

How to Base64 Encode Text (Without Breaking Unicode)

Encode text to Base64 online for free, with correct handling of Vietnamese, emoji, and other Unicode text — a common failure point in naive implementations.

By QR Ivify Team

How to Base64 Encode Text (Without Breaking Unicode)

Base64 shows up constantly in real development work — embedding an image as a data URL, encoding a value for an API header, preparing binary-safe text for a system that only accepts a limited character set. It's a simple, well-documented encoding — but the most common browser-native way to do it in JavaScript quietly breaks on anything outside plain ASCII.

Why btoa() Alone Isn't Enough

The browser's built-in btoa() function encodes a string to Base64, but it only works correctly on text made of characters in the Latin-1 range — feed it Vietnamese, emoji, or CJK text and it either throws an error or silently produces the wrong output, because btoa() expects each character to fit in a single byte, and Unicode text usually doesn't.

The fix is to convert the text to its UTF-8 byte representation first (via TextEncoder), then Base64-encode those bytes — not the raw string. QR Ivify's Base64 Encoder does exactly this, so Vietnamese, Chinese, Japanese, and emoji all encode correctly instead of throwing or corrupting.

Step by Step

  1. Open the Base64 Encoder.
  2. Type or paste text into the box.
  3. Click "Encode to Base64."
  4. Copy or download the result.

A Worked Example

Input: Hello World

Output: SGVsbG8gV29ybGQ=

The same approach correctly handles Xin chào, こんにちは, 你好, and 😀 — none of which a plain btoa() call could encode without either throwing or mangling the result.

Base64 Is an Encoding, Not Encryption

Worth being direct about this: Base64 doesn't hide or protect anything. It has no key, no secret — anyone who has the encoded string can decode it back to the original text in one line of code, or with any of the countless free decoders online, including this site's own. If you need to protect the content of something, Base64 encoding it does nothing toward that goal; it's purely a format conversion, useful for representing binary-safe data as plain text.

Frequently Asked Questions

Does this handle Vietnamese, emoji, and other Unicode text correctly? Yes — encoding goes through proper UTF-8 byte conversion first, so any Unicode text round-trips correctly rather than corrupting.

Is Base64 encoding the same as encryption? No — Base64 is an encoding, not encryption. It has no key or secret; anyone can decode it instantly. Don't use it to protect sensitive information.

Does this upload my text anywhere? No. Encoding happens entirely in your browser.

Can I encode a file, not just typed text? This tool encodes text you paste or type — for encoding a binary file, a format-specific tool is a better fit.

Try It

Need to Base64-encode text — including non-English text — correctly? QR Ivify's free Base64 Encoder handles Unicode properly. Need to decode a Base64 string instead? Try Base64 Decoder. Encoding a value for a URL? See URL Encoder.

base64 encoderdeveloper toolstutorial

Related articles