DEVELOPER TOOL

Base64 Encoder / Decoder

Encode text to Base64 or decode Base64 strings back to plain text. Handles Unicode characters with full UTF-8 support.

Result
Result will appear here...

Understanding Base64 Encoding

Binary Made Text-Safe

Base64 is a binary-to-text encoding scheme that transforms any data into a set of 64 ASCII characters (A-Z, a-z, 0-9, +, /). Invented for email attachments in the MIME standard (RFC 2045, 1996), it solves a fundamental problem: many protocols — HTTP headers, JSON, XML, email bodies — are text-only and corrupt raw binary data. Base64 guarantees safe transport by converting every 3 bytes of input into 4 ASCII characters, with = padding to handle inputs not divisible by 3.

The Math Behind the 33% Overhead

3 bytes (24 bits) → 4 Base64 characters (6 bits each)

Every 3 input bytes become 4 output characters — a fixed 33.3% size increase. A 1 MB image becomes ~1.33 MB when Base64-encoded. A 750 KB PDF embedded in a JSON payload grows to ~1 MB. This overhead is the price of text-safe transport. For comparison, hex encoding doubles the size (100% overhead), making Base64 the more efficient choice for binary-to-text conversion.

Where Base64 Lives in the Wild

Data URIs: Embed small images directly in CSS or HTML (data:image/png;base64,...) to eliminate HTTP requests. Icons under 4 KB are commonly inlined this way. HTTP Basic Auth: Credentials are encoded as base64(username:password) in the Authorization header. JWT Tokens: The header and payload are Base64URL-encoded (using - and _ instead of + and /). Email attachments: MIME encoding uses Base64 to embed files in plaintext email bodies.

Encoding is Not Encryption

A critical distinction: Base64 provides zero security. It is a reversible transformation, not a cryptographic operation. Anyone can decode a Base64 string instantly without any key. Storing passwords, API keys, or secrets in Base64 is equivalent to storing them in plain text. Real protection requires encryption (AES-256, ChaCha20) or hashing (SHA-256, bcrypt). Base64's sole purpose is format conversion for safe transport through text-only channels.

Frequently Asked Questions

What is the difference between Base64 and Base64URL?

Standard Base64 uses + and / as the 62nd and 63rd characters, plus = for padding. Base64URL (RFC 4648) replaces + with - and / with _ to make the output URL-safe without percent-encoding. JWT tokens use Base64URL. This tool uses standard Base64; to convert, replace - with + and _ with / in the encoded string.

How does this tool handle Unicode and non-ASCII text?

This tool encodes text as UTF-8 before applying Base64 encoding. A single emoji like “🚀” occupies 4 UTF-8 bytes and becomes 8 Base64 characters. Without proper UTF-8 handling, non-ASCII characters would be corrupted or produce incorrect output. The decode operation reverses this: Base64 to binary bytes, then UTF-8 to text.

Should I Base64-encode images for my website?

Only for small assets (under 4 KB). Base64 inlining eliminates an HTTP request but increases the CSS/HTML file size by 33%, and the encoded data cannot be cached separately. For images larger than 4 KB, serving them as separate files with proper caching headers is almost always more performant.