What Is Base64 Encoding?
Base64 is a group of binary-to-text encoding schemes that represent binary data in an ASCII string format. The name comes from the 64 characters used in the encoding alphabet: the 26 uppercase letters (A-Z), 26 lowercase letters (a-z), 10 digits (0-9), and two additional characters (+ and /).
Base64 was originally designed for safely transmitting binary data over channels that only support text, such as email (MIME) and early internet protocols. Today it's used extensively in web development for data URIs, API payloads, and authentication tokens.
How Base64 Encoding Works
Base64 encoding takes groups of 3 bytes (24 bits) from the input and splits them into 4 groups of 6 bits. Each 6-bit group maps to one of the 64 characters in the Base64 alphabet. If the input length isn't divisible by 3, the output is padded with '=' characters.
For example, the text 'Hi' (2 bytes) becomes 'SGk=' in Base64. The '=' indicates one byte of padding was needed. Decoding reverses this process exactly, recovering the original binary data.
Common Uses for Base64
Data URIs allow you to embed images, fonts, and other files directly in HTML or CSS using Base64 encoding (e.g., 'data:image/png;base64,...'). This eliminates an extra HTTP request but increases the HTML file size by ~33%.
HTTP Basic Authentication encodes credentials as Base64 (though this provides no security — always use HTTPS). JSON APIs sometimes use Base64 to include binary data in JSON payloads, since JSON only supports text. Email attachments are encoded in Base64 as part of the MIME standard.
Base64 vs. Other Encoding Schemes
URL encoding (percent-encoding) replaces unsafe characters with %XX sequences and is designed specifically for URLs. It's more efficient than Base64 for text that's mostly ASCII. Base32 uses a 32-character alphabet and produces longer output, but avoids ambiguous characters — useful for human-readable codes. Hexadecimal encoding doubles the input size (vs. 33% for Base64) but is simpler and universally supported.
Choose Base64 when you need to embed arbitrary binary data in a text format. Choose URL encoding for URL parameters. Choose hex for debugging and displaying binary data.
Frequently Asked Questions
Related Tools
Explore More Tools
Find this tool useful? Buy us a coffee to keep DuskTools free and ad-light.