Base64 Encoder/Decoder
Encode plain text to Base64 format or decode Base64 strings back to readable text instantly. This free online tool supports UTF-8 encoding and provides real-time conversion with character count statistics. Essential for developers working with APIs, data URLs, email attachments, and web development.
How to Use This Base64 Encoder/Decoder
- Select your mode: Click "Encode" to convert plain text to Base64, or "Decode" to convert Base64 strings back to readable text. The active mode is highlighted and determines how your input will be processed.
- Enter your content: Type or paste your content in the input text area. When encoding, enter any text including special characters and Unicode. When decoding, paste a valid Base64 string.
- View automatic conversion: The tool converts your input in real-time as you type. Watch the output area update immediately with each keystroke, making it easy to verify your conversion.
- Click Convert: While conversion happens automatically, you can click the "Convert" button to explicitly trigger the conversion, which is useful after pasting large amounts of text.
- Use the Swap button: Click "Swap" to move the output to the input field and switch modes. This is handy for verifying a round-trip conversion or continuing to work with the result.
- Copy your result: Click "Copy Result" to copy the converted output to your clipboard. The character count statistics help you verify the conversion produced the expected output length.
What is Base64 Encoding?
Base64 is a binary-to-text encoding scheme that represents binary data using a set of 64 printable ASCII characters. Developed in the 1980s for email systems, Base64 remains essential today for transmitting binary data through text-only channels. The encoding ensures data integrity when binary information must pass through systems designed to handle only text.
The name "Base64" comes from the fact that the encoding uses exactly 64 distinct characters to represent data. This alphabet consists of uppercase letters (A-Z), lowercase letters (a-z), digits (0-9), and two additional characters (typically + and /). These 64 characters can each represent 6 bits of binary data.
Base64 encoding increases data size by approximately 33% because it uses 4 characters to represent every 3 bytes of input data. While this overhead might seem wasteful, it is an acceptable trade-off for guaranteed compatibility with text-based transmission systems and storage formats.
How Base64 Encoding Works
The encoding process divides input data into groups of three bytes (24 bits). These 24 bits are then split into four groups of 6 bits each. Each 6-bit group is converted to one of the 64 characters in the Base64 alphabet. The character mapping is: A-Z represents values 0-25, a-z represents 26-51, 0-9 represents 52-61, + represents 62, and / represents 63.
When the input data length is not divisible by 3, padding is required. If there is one remaining byte, two Base64 characters are generated followed by two equals signs (==). If there are two remaining bytes, three Base64 characters are generated followed by one equals sign (=). The padding ensures the output length is always a multiple of 4.
Encoding example: The text "Man" (bytes: 77, 97, 110) becomes "TWFu". The three bytes are: 01001101 01100001 01101110. Split into 6-bit groups: 010011 010110 000101 101110, which map to indices 19, 22, 5, 46, corresponding to characters T, W, F, u.
Common Use Cases for Base64
Data URLs: Embedding images directly in HTML or CSS using data:image/png;base64,... eliminates the need for separate image file requests, reducing HTTP overhead for small images.
Email attachments: MIME encoding uses Base64 to include binary files like images and documents in email messages, which are fundamentally text-based protocols.
API data transmission: When sending binary data through JSON APIs, Base64 encoding ensures the data remains intact regardless of any character encoding transformations that might occur during transmission.
Basic authentication: HTTP Basic Authentication encodes username:password credentials in Base64. While not encryption, it ensures special characters in passwords do not break the HTTP header format.
Storing binary in databases: Some databases or data formats that only support text can store binary data as Base64-encoded strings, though dedicated binary types are usually more efficient.
Base64 Variants
Standard Base64: Uses the alphabet A-Za-z0-9+/ with = for padding. This is the most common variant and what this tool uses.
URL-safe Base64: Replaces + with - and / with _ to avoid characters that have special meaning in URLs. Often omits padding. Used in JWT tokens and URL parameters.
Base64 without padding: Some implementations omit the trailing = characters. The decoder can infer the original length from the string length since Base64 output is always a multiple of 4.
Important Considerations
Base64 is an encoding, not encryption. It provides no security and can be easily decoded by anyone. Never use Base64 alone to protect sensitive information. For security, use proper encryption before Base64 encoding if the data must be transmitted as text. This tool supports UTF-8 encoding, allowing you to Base64-encode text containing Unicode characters, emojis, and special characters from any language.