๐ Base64 Encoder / Decoder
Encode plain text โ Base64, or decode Base64 โ plain text. Full UTF-8 & Unicode support.
Base64 Encoding: What It Actually Is and Why You Keep Running Into It
If you have ever peeked at an email's raw source, embedded an image directly into an HTML file, or worked with any kind of API that sends binary data over the web, you have almost certainly seen Base64 without knowing what you were looking at. A wall of letters, numbers, plus signs, and forward slashes, sometimes ending in one or two equals signs โ that is Base64. And understanding it takes about five minutes once someone explains it properly.
The Core Problem Base64 Was Designed to Solve
Computers speak in binary โ zeros and ones. But most communication channels that carry data between systems were originally designed only for text. The old email protocols, for instance, were built in an era when people assumed you would only ever send readable ASCII characters. Nobody imagined you would want to email a photograph or a ZIP file.
So engineers had a real problem. How do you send binary data โ like a JPEG image or a compiled executable โ through a channel that only understands text? You convert the binary data into a text representation. That is exactly what Base64 does. It takes raw bytes and represents them using only 64 printable ASCII characters: the 26 uppercase letters (AโZ), the 26 lowercase letters (aโz), the digits 0โ9, and the characters plus (+) and forward slash (/). That gives you 64 symbols, hence the name.
The equals sign (=) is used as padding at the end when the input length is not divisible by three. This is why you often see one or two trailing equals signs in Base64 output โ it is not random, it is a structural necessity of the encoding scheme.
How the Encoding Actually Works
Base64 processes data in chunks of three bytes at a time. Three bytes equal 24 bits. Those 24 bits are then split into four groups of 6 bits each. Since 2 to the power of 6 is 64, each 6-bit group maps to exactly one character in the Base64 alphabet. So every three bytes of input becomes four characters of output.
This means Base64 encoded data is always about 33% larger than the original. If you start with 3 KB of binary data, the Base64 version will be roughly 4 KB. That is the trade-off โ you get universal text compatibility but pay a size cost.
When the input is not cleanly divisible by three bytes, Base64 pads the output. If there is one leftover byte, the output ends in two equals signs (==). If there are two leftover bytes, the output ends in one equals sign (=). If the input divides evenly by three, there is no padding at all.
UTF-8 and Why It Matters for Text Encoding
Here is where things get slightly more interesting for modern web developers. The original Base64 specification was designed for bytes, not characters. In the ASCII era, one character equaled one byte, so there was no ambiguity. But today we use UTF-8, where a single character can be anywhere from one to four bytes wide.
Take a Hindi character like "เคจ" โ that is a single character in your text but it takes three bytes in UTF-8 encoding. A Japanese kanji might take three bytes. Even an emoji like ๐ takes four bytes. If you try to Base64 encode a string containing these characters using a naive approach โ just treating each character as one byte โ you will get errors or corrupted output.
The correct approach for text containing non-ASCII characters is to first encode the string as UTF-8 bytes, then apply Base64 to those bytes. In JavaScript, this is done using encodeURIComponent combined with unescape before calling btoa(). The reverse process for decoding is atob() followed by escape and decodeURIComponent. This tool handles that entire process automatically, which is why it correctly handles Hindi text, Arabic script, Chinese characters, emoji, and any other Unicode content you throw at it.
Real-World Places You Encounter Base64
Base64 shows up constantly in modern software development, often in places you might not expect.
Email attachments are the original use case. When you send a photo through Gmail, the email server internally represents that image as a Base64 string in the email's MIME structure. Your email client decodes it transparently before displaying it.
Data URLs in HTML and CSS let you embed images, fonts, and other binary assets directly in your code as Base64 strings. Instead of linking to an external file with a URL, you write src="data:image/png;base64,iVBORw0KGgo..." and the browser decodes the image inline. Useful for small icons where you want to avoid an extra network request.
API authentication frequently uses Base64. HTTP Basic Authentication, for example, sends your username and password as a Base64-encoded string in the request header. It is worth noting that Base64 is not encryption โ anyone who intercepts the header can decode it trivially. That is why Basic Auth must always be used over HTTPS.
JSON Web Tokens (JWTs) are made of three Base64URL-encoded sections separated by dots. The payload section of a JWT, which contains claims like your user ID and expiry time, is simply a Base64URL-encoded JSON object. You can paste any JWT into a Base64 decoder and read the payload directly โ another reminder that Base64 is encoding, not encryption.
Environment variables and configuration sometimes store binary secrets (like TLS certificates or SSH keys) as Base64 strings, since environment variables are text-only and many deployment systems cannot handle raw binary in config values.
Base64 Is Not Encryption โ This Matters
It is worth being direct about this because the misconception causes real security problems. Base64 encoding is completely reversible by anyone without a key, password, or any secret knowledge. It is a format transformation, not a security measure. If you Base64 encode a password and store it somewhere, that password is effectively stored in plain text โ any developer who knows what Base64 is can decode it in seconds.
Actual security requires hashing (for passwords) or encryption (for sensitive data at rest or in transit). SHA-256, bcrypt, AES, RSA โ these are security tools. Base64 is a utility for representing bytes as text. Understanding the difference will save you from building systems with a false sense of security.
The URL-Safe Variant
Standard Base64 uses the + and / characters, both of which have special meanings in URLs. If you try to put a standard Base64 string into a query parameter, those characters can break the URL parsing. The solution is Base64URL encoding, which replaces + with - and / with _, and typically omits the padding equals signs. This variant is used in JWTs, certain OAuth flows, and other web contexts where the encoded string needs to appear in a URL. When you decode a JWT payload, you may need to substitute these characters back before your Base64 decoder can process it correctly.
Using This Tool Effectively
The encoder accepts any text input, including Unicode and multi-byte characters, and produces a valid Base64 string. The decoder takes a Base64 string and recovers the original text. The swap button lets you move the output back into the input field for chained operations โ for example, if you want to decode something and then re-encode a modified version of it.
Everything runs locally in your browser. Your input never touches a server, which matters if you are working with anything sensitive. That said, remember: if you are encoding something to Base64 because you think it will be secure, it will not be. Use this tool for what Base64 is actually for โ format conversion, debugging, development, and working with encoded content you encounter in APIs and files.