Base64 Converter
Encode and decode text to/from Base64 format.
What is Base64?
Base64 is a group of binary-to-text encoding schemes that represent binary data in an ASCII string format. It is commonly used to embed image data in CSS or HTML, and for basic obfuscation of data in URLs or headers.
How Base64 Works
The term Base64 comes from a specific MIME content transfer encoding. It uses a set of 64 characters (A-Z, a-z, 0-9, +, /) to represent data. Every three bytes of binary data are converted into four Base64 characters.
Common Use Cases
- Data URIs: Embedding small images or fonts directly into CSS or HTML files to reduce HTTP requests.
- Email Attachments: Binary files are encoded into Base64 to ensure they remain intact during transit across text-only protocols like SMTP.
- API Authentication: Basic auth headers often use Base64 to encode the "username:password" string.
Encoding vs. Encryption
A common misconception is that Base64 is a form of encryption. It is not. Because the algorithm is standardized and requires no key, any Base64 string can be easily decoded. Never use Base64 to "secure" sensitive information.
UTF-8 Support
Unlike basic `atob()` and `btoa()` functions which only support ASCII, our tool uses the `TextEncoder` and `TextDecoder` APIs to correctly handle emojis and special characters.
How to Use
- Ensure the Mode is set to what you need (Encode for text to Base64, Decode for Base64 to text).
- Paste your source material into the Input box.
- The tool will automatically convert the text as you type.
- If the input is invalid Base64 (during decoding), an error message will appear.
- Click the Copy icon in the output area to save the result.
Frequently Asked Questions
Why are there equal signs (=) at the end?
The equal sign is used for padding. Since Base64 groups characters into blocks of four, if the source data isn't a multiple of three bytes, padding is added to complete the block.
Can I encode images?
This specific tool is designed for text strings. For image encoding, a dedicated file-to-Base64 converter is usually preferred.
Does Base64 increase file size?
Yes. Base64 encoding typically increases the data size by about 33% compared to the original binary or text data.
Is Base64 URL-safe?
Standard Base64 contains "+" and "/" which have special meanings in URLs. A "URL-safe" variant exists that replaces these with "-" and "_".