Base64 Encoding Explained: How It Works and When to Use It
Base64 encoding converts binary data into a safe ASCII text format. It is used everywhere: email attachments, JWT tokens, data URIs, API payloads, and HTTP Basic Authentication headers.
How it works: Base64 takes 3 bytes (24 bits) of input and encodes them as 4 characters from a 64-character alphabet: A–Z, a–z, 0–9, +, and /. The = character is used for padding when the input is not a multiple of 3 bytes. This makes the output approximately 33% larger than the input.
Why Base64? Many systems designed for text (email, HTTP headers, JSON) cannot safely handle arbitrary binary data. Base64 converts binary to a subset of ASCII that passes through any text-based system unchanged. It is encoding, not encryption — the original data is fully recoverable by anyone with the encoded string.
Common uses: - Email attachments (MIME): Binary files encoded as Base64 within email bodies - JWT tokens: Header and payload encoded as Base64url (using - and _ instead of + and /) - Data URIs: Small images embedded directly in HTML/CSS: data:image/png;base64,... - HTTP Basic Auth: "username:password" encoded as Base64 in the Authorization header - API payloads: Binary data sent through JSON APIs
Base64 vs Base64url: Base64url replaces + with - and / with _ to make the output safe for URLs and filenames without percent-encoding. JWT tokens use Base64url. To decode a Base64url string with Tooler, replace - with + and _ with / first.
Use Tooler's Base64 tool to encode and decode text strings.