Text to Base64 Encoder
Encode plain text, Unicode, JSON, HTML, or code snippets to Base64. Output updates live — get Base64, Base64URL, Data URI, or JSON with one click.
Enter or paste text above — Base64 output appears instantly
Need to decode Base64 back to text?
Decode Base64 strings to readable text, with UTF-8, Unicode, and Emoji support.
How to Encode Text to Base64
Enter or Paste Text
Type any text — plain English, Unicode characters, JSON, HTML, code snippets, or Emoji. All languages are supported.
Get Output Instantly
Base64 output is generated in real time as you type. Switch between the Base64, Base64URL, Data URI, and JSON tabs to get the format you need.
Copy and Use
Click Copy to send the encoded string to your clipboard, then paste it into your API, config file, HTTP header, or code.
Text Base64 Examples
Common inputs and their Base64 output.
| Input | Base64 | Note |
|---|---|---|
| Hello | SGVsbG8= | Simple word |
| Hello, Base64 Files! | SGVsbG8sIEJhc2U2NCBGaWxlcyE= | With space and punctuation |
| 你好 | 5L2g5aW9 | Chinese (UTF-8) |
| {"key":"value"} | eyJrZXkiOiJ2YWx1ZSJ9 | JSON string |
| <h1>Hello</h1> | PGgxPkhlbGxvPC9oMT4= | HTML snippet |
| 😀 | 8J+YgA== | Emoji (4-byte UTF-8) |
Encode Text to Base64 in JavaScript
Use btoa() for ASCII text, or TextEncoder for full Unicode support.
JavaScript — Encode Text to Base64
// ASCII only
btoa('Hello')
// → "SGVsbG8="
// UTF-8 (recommended — handles all Unicode)
function encodeBase64(text) {
const bytes = new TextEncoder().encode(text)
let binary = ''
bytes.forEach(b => binary += String.fromCharCode(b))
return btoa(binary)
}
encodeBase64('Hello 你好 🌐')
// → "SGVsbG8g5L2g5aW9IPCfjpA="
// Base64URL (safe in URLs and JWT)
function toBase64Url(b64) {
return b64
.replace(/\+/g, '-')
.replace(/\//g, '_')
.replace(/=/g, '')
}UTF-8 and Unicode Support
The standard btoa() only accepts ASCII characters. For multi-byte text — Chinese, Japanese, Arabic, accented characters, or Emoji — you must encode to UTF-8 bytes first.
This tool uses TextEncoder to convert text to UTF-8 bytes before Base64 encoding. That means:
- Supports all 1.1 million Unicode code points
- Emoji, CJK characters, and right-to-left scripts encode correctly
- A decoder must also use UTF-8 to recover the original text
- Base64 output length depends on UTF-8 byte count, not character count
Base64 vs. Base64URL
Standard Base64
- Uses
+and/ - Uses
=padding - Email, file storage, data embedding
Base64URL
- Uses
-and_ - No padding
- JWT tokens, URLs, filenames
Need a dedicated Base64URL encoder/decoder?
Base64URL EncoderFrequently Asked Questions
How do I encode text to Base64 in JavaScript?
For pure ASCII text, use btoa('Hello') → 'SGVsbG8='. For UTF-8 text (Unicode, Emoji, CJK characters), encode via TextEncoder first: const b = new TextEncoder().encode(text), then convert the bytes to a binary string before calling btoa(). This tool handles that automatically.
What's the difference between Base64 and Base64URL?
Standard Base64 uses + and / characters, with = padding. These characters cause problems in URLs and filenames. Base64URL replaces + with -, replaces / with _, and removes = padding — making it safe for URLs, query strings, JWT tokens, and filenames. The encoded data is otherwise identical.
Does Base64 encoding support all languages and Emoji?
Yes, when using UTF-8 encoding (the default). UTF-8 can represent all Unicode code points, covering every language, Emoji, and symbol in the world. The tool encodes your text to UTF-8 bytes first, then Base64-encodes those bytes.
Why does Base64 output end with = or ==?
Base64 processes input in groups of 3 bytes, producing 4 characters. If the input length isn't a multiple of 3, one or two = characters are added at the end as padding, making the output length a multiple of 4. Base64URL removes this padding.
Can I encode JSON or HTML to Base64?
Yes. Paste any JSON object, HTML fragment, CSS rule, or code snippet into the input. The tool encodes the entire string as UTF-8 Base64. This is common when embedding structured data in HTTP headers, config files, and API fields.
Where is the text processed?
Entirely in your browser. Your text never leaves your device. Encoding uses the browser's built-in TextEncoder and btoa() APIs — no server, no network request.