Encode text to Base64 or decode Base64 back to plain text.
Base64 is a binary-to-text encoding scheme that converts arbitrary binary data into a text-only format using 64 safe ASCII characters (A-Z, a-z, 0-9, +, /). Originally standardized in RFC 2045 as part of MIME (Multipurpose Internet Mail Extensions), Base64 has become essential for any system needing to represent binary data in text-only environments. The encoding is not designed for compression or cryptography—it's purely a transport mechanism that ensures binary data can safely pass through systems that only handle text. Every 3 bytes of binary data get encoded as 4 Base64 characters, resulting in approximately 33% larger output. The character set was carefully chosen to include only characters universally safe across email systems, HTTP headers, and text protocols. Padding characters ('=') are added at the end to ensure output length is always a multiple of 4, maintaining consistency. Base64 is reversible—any valid Base64 string can be decoded back to the original binary data losslessly. The encoding is stable and deterministic: the same input always produces identical output. Common applications include embedding images directly in HTML as data URIs (data:image/png;base64,...), encoding binary files for email transmission, storing binary data in JSON/XML documents, representing API credentials in HTTP Basic Authentication headers, encoding file attachments in web requests, and transmitting binary protocol buffers in text-based communication channels.
Using the Base64 encoder and decoder is intuitive and supports multiple workflows. To encode text, simply paste your content into the input field on the left and click "Encode →" to convert it to Base64. The output appears immediately in the right textarea, ready to copy. For decoding, paste Base64 text into the input field and click "← Decode" to convert it back to plain text or binary representation. The "Swap" button exchanges the content between input and output fields, useful when you want to reverse operations or re-encode already-decoded text. After encoding or decoding, use the "Copy" button to copy the result directly to your clipboard without manual selection. The status message displays the character count of the output, helping you understand how much the encoding expands your data. The tool handles both plain ASCII text and UTF-8 encoded text with special characters correctly. If you paste invalid Base64 (not padded correctly or containing invalid characters), the decoder will display an error message indicating the problem. Clear all fields at once using the "Clear" button to start fresh. The two-column layout lets you compare input and output simultaneously, and you can resize the textarea fields to work with larger content blocks. Processing happens instantly in the browser—there's no latency waiting for server responses.
Base64 encoding solves practical problems across web development, APIs, and data transmission. Email systems use Base64 to encode binary attachments because SMTP (Simple Mail Transfer Protocol) only handles text. When you attach an image to an email, the email client Base64-encodes the binary image file before sending, and the recipient's email client decodes it back to the original binary. Web developers use Base64 data URIs to embed images directly in HTML without separate image files—this is particularly useful for small icons and logos that would require separate HTTP requests. Frontend applications encode credentials as "username:password" in Base64 format for HTTP Basic Authentication (Authorization header). API developers sometimes Base64-encode binary data when JSON payloads must contain only text-safe characters, as JSON strings cannot directly contain binary null bytes. When working with file uploads in web applications, some frameworks Base64-encode the file content in the JSON request body. Configuration tools often Base64-encode sensitive data in configuration files to provide light obfuscation (though this is not encryption—it's easily reversible). Database administrators use Base64 encoding to store binary data like images, PDFs, or serialized objects as text in databases that don't support binary types. Software licensing sometimes uses Base64-encoded license keys for distribution. Webhook systems that must transmit binary content often Base64-encode it since HTTP headers and JSON bodies must be text-safe.
Base64 encoding works by taking binary data and converting it into a text representation using a standard character set of 64 characters. The algorithm groups the input binary data into 3-byte (24-bit) chunks. Each 24-bit chunk is then divided into four 6-bit segments, and each 6-bit segment (values 0-63) maps to a character in the Base64 alphabet. The standard alphabet is: A-Z (26 chars), a-z (26 chars), 0-9 (10 chars), plus '+' and '/' (2 chars)—totaling exactly 64 characters. If the input length is not a multiple of 3 bytes, padding is added: one or two '=' characters pad the output to make the length a multiple of 4. The decoder reverses this process: it takes each Base64 character, looks up its numeric value (0-63), extracts the 6 bits, recombines them into 8-bit bytes, and reconstructs the original data. This transformation is deterministic and lossless. The encoding expands data by a factor of 4/3 (33% larger) because 4 Base64 characters (4×6=24 bits) encode the same information as 3 bytes (3×8=24 bits). For the tool implementation, JavaScript uses built-in functions: btoa() for encoding (binary-to-ASCII) and atob() for decoding (ASCII-to-binary). These functions handle standard Base64 but may need wrapping to support Unicode text, which the tool does using encodeURIComponent() and decodeURIComponent() to ensure UTF-8 text encodes/decodes correctly.
Q: Is Base64 encryption?
A: No. Base64 is encoding, not encryption. It's easily reversible and provides no security. Anyone with a Base64 string can immediately decode it to see the original content. For actual security, use cryptographic algorithms like AES. Base64 is just a safe way to represent binary data as text.
Q: Why is Base64 output always a multiple of 4 characters?
A: Because each 3 input bytes encode to exactly 4 Base64 characters (3×8 bits = 4×6 bits). If the input isn't a multiple of 3 bytes, padding characters ('=') are added to maintain this ratio, ensuring compatibility with systems expecting Base64 output in 4-character chunks.
Q: Can I encode an entire file with Base64?
A: Yes, any binary file can be Base64 encoded, but this tool works best with smaller files (under 10MB due to browser memory limits). For large files, use command-line tools like 'base64' on Linux/Mac or specialized file encoding software.
Q: What's the difference between standard Base64 and URL-safe Base64?
A: Standard Base64 uses '+' and '/' characters, but these have special meaning in URLs. URL-safe Base64 (RFC 4648) replaces '+' with '-' and '/' with '_', making the output safe to include in URLs without encoding. This tool uses standard Base64.
Q: Why does my decoded text look garbled?
A: This usually means the input wasn't valid Base64 or wasn't Base64-encoded in the first place. Ensure the entire Base64 string is included, including all '=' padding characters. Also verify the original text used UTF-8 encoding, not other encodings like Latin-1.
Q: How can I use Base64 in my code?
A: Most languages have built-in Base64 support: JavaScript (btoa/atob), Python (base64 module), Java (java.util.Base64), PHP (base64_encode/base64_decode), Node.js (Buffer class), and more. See your language documentation for details.
Remember that Base64 is not encryption and shouldn't be used to protect sensitive data—use actual cryptography for security. When embedding images as Base64 data URIs in HTML, consider file size impact since the embedded content is larger than the original binary. For frequently-loaded images, separate image files with caching are usually faster than inline Base64 URIs. When transmitting Base64 over HTTP, it can still be intercepted unless HTTPS is used. Document which data is Base64-encoded in your API documentation to avoid confusion by downstream users. Standard Base64 uses characters unsafe in URLs ('+' and '/'); use URL-safe Base64 (replacing those with '-' and '_') when encoding for URLs. When debugging authentication issues, remember HTTP Basic Authentication encodes credentials as "user:pass" in Base64 before transmission—never expose this to logs. Test your Base64 encoding with both ASCII and Unicode text to ensure proper handling. Keep the maximum input size in mind when building web applications; consider server-side encoding for large binary files.
Base64 encoding takes groups of 3 bytes (24 bits) and converts them into 4 ASCII characters from a set of 64 characters (A-Z, a-z, 0-9, +, /). The encoded output is always ~33% larger than the original data.