Base64 Files
UTF-8 · Unicode · Live encode

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.

Text to Base64UTF-8

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.

Base64 to Text

How to Encode Text to Base64

1

Enter or Paste Text

Type any text — plain English, Unicode characters, JSON, HTML, code snippets, or Emoji. All languages are supported.

2

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.

3

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.

InputBase64
HelloSGVsbG8=
Hello, Base64 Files!SGVsbG8sIEJhc2U2NCBGaWxlcyE=
你好5L2g5aW9
{"key":"value"}eyJrZXkiOiJ2YWx1ZSJ9
<h1>Hello</h1>PGgxPkhlbGxvPC9oMT4=
😀8J+YgA==

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 Encoder

Frequently 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.