🔐 Base64 Encoder / Decoder
Convert text to Base64 encoding or decode Base64 strings back to readable text.
What is this tool?
A Base64 encoder and decoder is a utility that converts data between plain text and Base64 representation. Base64 is a binary-to-text encoding scheme that represents binary data using 64 printable ASCII characters: uppercase and lowercase letters, digits, plus, and slash, with equals signs used for padding. This encoding is widely used in web development, email systems, and data interchange because it allows binary data to be safely transmitted through text-only channels such as JSON, XML, HTML, and email without corruption. Common use cases include embedding images directly in HTML or CSS as data URLs, encoding authentication credentials in HTTP headers, storing binary data in JSON payloads, transmitting file attachments in email, and encoding API tokens. Base64 encoding increases data size by approximately 33 percent, since every 3 bytes of original data become 4 Base64 characters. This tool handles both encoding and decoding instantly, supporting Unicode text through proper UTF-8 conversion. It also handles edge cases like padding and malformed input gracefully, providing clear error messages.How it works
The Base64 encoder and decoder uses built-in JavaScript functions to perform the conversion. For encoding, it first converts the input text string to a UTF-8 byte sequence using the TextEncoder API, then applies the btoa function to produce the Base64 string. This two-step process ensures correct handling of Unicode characters, since btoa alone only works correctly with Latin-1 characters. For decoding, it applies the atob function to decode the Base64 string into a binary string, then converts the byte sequence back to a UTF-8 text string. The tool validates that the input for decoding is well-formed Base64, checking for valid characters, correct padding, and appropriate length. If the input is not valid Base64, it displays a clear error message. For encoding, it automatically adds the correct padding equals signs at the end of the output. All processing occurs locally in your browser.How to use
- Enter the text you want to convert in the input text area.
- To convert text to Base64, press the Encode button. The text will be represented as a Base64 string.
- To convert a Base64 string back to readable text, paste it and press the Decode button.
- If decoding fails, check that your input is a valid Base64 string with only valid characters and correct padding.
- Copy the result from the output area using the copy button.
Frequently Asked Questions
Frequently Asked Questions
Why does Base64 make my text longer?
Base64 encoding represents every 3 bytes of original data as 4 Base64 characters, so the output is approximately 33 percent larger than the input. This overhead is inherent to the encoding scheme and is the trade-off for being able to represent binary data using only printable ASCII characters.
Can it encode binary files like images?
No, this tool is designed for text input only. To encode binary files like images or PDFs, you would need a tool that reads the file as a byte array first. However, once you have the Base64 string of a file, you can decode it here. For embedding images in HTML or CSS, use a dedicated image-to-Base64 converter.
Does it handle Unicode characters correctly?
Yes. The tool uses the TextEncoder API to properly convert Unicode text to UTF-8 bytes before encoding. This means Chinese, Japanese, Korean, emoji, and other multi-byte characters are encoded correctly. Without this step, btoa alone would fail or produce incorrect results for non-ASCII characters.
Is Base64 encryption?
No. Base64 is an encoding scheme, not encryption. Anyone can decode Base64 instantly without any key or password. Never use Base64 to protect sensitive information. For security, use proper encryption algorithms. Base64 is meant for data transport and representation, not confidentiality.
Tips & Advice
Base64 is not encryption and should never be used to protect sensitive data. Anyone with the encoded string can decode it instantly. Common legitimate uses include embedding small images in CSS or HTML, encoding HTTP Basic Authentication headers, storing binary data in JSON, and transmitting data through text-only channels. When decoding Base64, always verify that the output is what you expect, since malformed Base64 can produce garbage output. For large data, remember the 33 percent size overhead when planning storage or bandwidth. If you need to encode binary files, use a dedicated file-to-Base64 tool. All processing happens locally in your browser for maximum privacy.