Text to Base64

Encode Unicode text to Base64 and decode it back – emoji included.

0 chars
0 words
0 lines
0 chars
0 words
0 lines

Text to Base64 Converter with Full Unicode Support

This converter turns any piece of text into Base64 and decodes Base64 back into readable text. It was built for real-world, multilingual content: Turkish letters, German umlauts, Chinese and Japanese characters, right-to-left scripts, and emoji are all handled correctly. Everything runs locally in your browser, so the text you paste never touches a server.

Why plain btoa() breaks on Unicode

JavaScript's btoa() was designed in the days of Latin-1 and treats each character as a single byte. As soon as the string contains something like ş, €, or 😀, it throws an InvalidCharacterError. The correct approach is to encode the string as UTF-8 first, which turns every character into one to four bytes, and then Base64-encode the bytes. That is exactly what this page does. For example, çay becomes the bytes c3 a7 61 79 and the Base64 string w6dheQ==, and 👍 becomes 8J+RjQ==.

How to use it

Type or paste text in the input box and the Base64 appears instantly. Switch to Base64 to Text (or press the swap button) to reverse the process. You can load a .txt file, download the result, or click Sample to see a multilingual example.

Options

  • URL-safe swaps + and / for - and _, handy for query strings and tokens.
  • Padding keeps or removes the trailing = signs.
  • Line wrap splits long output at 76 or 64 characters for email bodies and PEM-style blocks.

When you need Unicode-safe Base64

Typical cases include storing user-generated text inside JSON Web Tokens, putting localized strings into environment variables, sending message payloads through queues that only accept ASCII, and debugging API responses that contain Base64-encoded names or addresses. If your input is strictly English 7-bit text, the stricter ASCII to Base64 tool will warn you about accidental non-ASCII characters. To see the raw UTF-8 bytes behind the text, try Hex to Base64.

Frequently Asked Questions

The browser's btoa() only accepts characters with code points up to 255. Emoji, Chinese, Cyrillic, and many Turkish letters (like ş or ğ) are outside that range, so btoa() fails. This tool first converts the text to UTF-8 bytes and then Base64-encodes those bytes, which works for every Unicode character.

An emoji like 🚀 takes four bytes in UTF-8. Four bytes need six Base64 characters (plus padding), while a plain letter like 'a' needs only one byte. The more non-Latin characters your text contains, the longer the Base64 output becomes compared to the visible text length.

Yes. UTF-8 is lossless, so every character, line break, tab, and emoji comes back exactly. If a Base64 string decodes to an error instead, it was probably created from binary data or from text in a legacy code page rather than UTF-8.

In modern JavaScript use btoa(String.fromCharCode(...new TextEncoder().encode(text))) or Uint8Array.prototype.toBase64() where available. In Python use base64.b64encode(text.encode('utf-8')), and in PHP base64_encode($text) on a UTF-8 string.