Base64 Encode & Decode

Encode text to Base64 or decode Base64 strings back to readable text. Everything runs locally in your browser.

📝 Input

📤 Output

What Is Base64 Encoding?

Base64 is a binary-to-text encoding scheme that represents binary data as a string of printable ASCII characters. It works by taking groups of three bytes (24 bits) and splitting them into four 6-bit values, each mapped to one of 64 characters: A–Z, a–z, 0–9, plus sign (+), and forward slash (/). A padding character (=) is used when the input length is not divisible by three.

Base64 encoding was designed to safely transmit binary data through systems that only handle text, such as email (MIME), XML documents, JSON web tokens (JWTs), and data URIs in HTML/CSS. It increases the data size by approximately 33%, which is the trade-off for universal text compatibility.

Common Use Cases for Base64

Developers frequently encounter Base64 in several contexts. Embedding small images directly in HTML or CSS using data URIs avoids additional HTTP requests and can improve page load performance for icons and small graphics. API authentication often uses Base64 — HTTP Basic Authentication encodes the username and password as a Base64 string in the Authorization header. JSON Web Tokens (JWTs) use Base64URL encoding (a URL-safe variant) for their header and payload sections. Email attachments are typically Base64-encoded within MIME messages to ensure binary files survive transmission through text-only email relays.

Base64 vs. Encryption

A common misconception is that Base64 provides security. It does not. Base64 is an encoding scheme, not an encryption algorithm. Anyone can decode a Base64 string without any key or secret. Never use Base64 alone to protect sensitive information like passwords, tokens, or personal data. For actual security, use proper encryption algorithms such as AES or RSA, and established protocols like TLS/HTTPS.

How This Tool Works

This tool uses your browser's built-in btoa() and atob() functions for encoding and decoding, with additional handling for Unicode characters through the TextEncoder and TextDecoder APIs. This ensures full support for non-ASCII characters including emoji, Chinese, Arabic, and other multi-byte character sets. No data is transmitted to any server.

Frequently Asked Questions

Can Base64 handle Unicode and emoji?
Yes. This tool correctly handles Unicode text including characters from all languages and emoji. It first converts the text to UTF-8 bytes before applying Base64 encoding, ensuring full compatibility with multi-byte characters.
Why does Base64 make the output larger than the input?
Base64 encoding converts every 3 bytes of input into 4 characters of output, resulting in approximately 33% size increase. This overhead is the cost of representing arbitrary binary data using only 64 safe ASCII characters.
What is Base64URL and how is it different?
Base64URL is a variant that replaces + with - and / with _ to make the output safe for use in URLs and filenames. It also typically omits the = padding. It is used extensively in JWTs and other web standards.
Is there a size limit for encoding?
Since this tool runs in your browser, the practical limit depends on your device's memory. Most modern browsers can handle encoding strings of several megabytes without difficulty.
Copied to clipboard!