Base64 Encoder & Decoder

Encode any plain text to a Base64 string or decode Base64 back to readable text. Full Unicode and emoji support, entirely client-side - your data never leaves your browser.

Try These Examples

  • Encode: Hello, World! 🚀 This is a Base64 encoding test.
  • Encode: {"user":"alice","role":"admin","iat":1700000000}
  • Decode: SmF2YVNjcmlwdCBpcyBhd2Vzb21lIQ==

How It Works

Base64 is a binary-to-text encoding scheme that converts binary data into a string of 64 printable ASCII characters: A-Z, a-z, 0-9, +, and /, with = used for padding. Every three bytes of input become four Base64 characters, which is why encoded output is roughly 33% larger than the original.

JavaScript's btoa() and atob()

Browsers provide two built-in functions for Base64 work:

  • btoa() - encodes a binary string to Base64
  • atob() - decodes a Base64 string back to a binary string

However, btoa() only accepts Latin-1 characters (code points 0–255). If you pass a string with characters outside that range - such as emoji, Chinese characters, or accented letters - it throws an error.

Handling Unicode

This tool solves the Unicode problem by using the TextEncoder and TextDecoder APIs. When encoding, the text is first converted to a UTF-8 byte sequence with TextEncoder, then each byte is mapped to a Latin-1 character that btoa() can handle. When decoding, the reverse process converts the binary string from atob() back into a UTF-8 byte array, which TextDecoder turns into a proper Unicode string.

Common Uses for Base64

  • Embedding images in CSS or HTML via data URIs
  • Encoding binary attachments in email (MIME)
  • Transmitting binary data in JSON payloads or URL parameters
  • Encoding credentials in HTTP Basic Authentication headers
  • Storing small binary blobs in text-based configuration files

Frequently Asked Questions

What is Base64 encoding?

Base64 is a binary-to-text encoding scheme that represents binary data as a string of printable ASCII characters. It converts every three bytes of input into four characters from a 64-character alphabet (A–Z, a–z, 0–9, +, /) plus = for padding. It is commonly used to embed binary data in text-based formats like JSON, HTML, CSS, and email.

Can Base64 encode Unicode and emoji?

JavaScript's built-in btoa() function only handles Latin-1 characters. To encode Unicode text (including emoji), you first convert the string to a UTF-8 byte sequence using TextEncoder, then encode those bytes with btoa(). This tool handles that conversion automatically so you can encode any text without errors.

Is Base64 encryption?

No. Base64 is an encoding scheme, not encryption. It does not provide any security or confidentiality. Anyone can decode a Base64 string back to its original value without a key. If you need to protect sensitive data, use proper encryption algorithms instead.

Why does Base64 make data larger?

Base64 represents every 3 bytes of input as 4 ASCII characters, resulting in roughly a 33% increase in size. This overhead is the trade-off for being able to safely transmit binary data through text-only channels like email, JSON payloads, and URL parameters.

Related Tools

← Back to all tools