What is Base64?
Base64 is an encoding scheme that converts binary data into a set of 64 printable ASCII characters. It's used to safely transmit binary data (images, files, binary protocols) through systems that only handle text.
The 64 characters are: A–Z, a–z, 0–9, +, / (with = used for padding).
How Base64 Works
Base64 takes 3 bytes (24 bits) of input and converts them into 4 Base64 characters (6 bits each):
1. Take 3 bytes of binary data
2. Split into four 6-bit groups
3. Map each group to the Base64 alphabet
Example:
- Input:
Hi(ASCII: 72, 105) - Binary:
01001000 01101001 - Base64 output:
SGk=(with=padding)
This means Base64 increases data size by approximately 33%.
Common Uses of Base64
| Use Case | Why Base64? |
|---|
|---|---|
| Email attachments (MIME) | Email protocols handle text only |
|---|---|
| JWT tokens | Safely embed JSON in HTTP headers |
| Data URIs | Embed images directly in HTML/CSS |
| API responses | Encode binary files in JSON |
| Cookies | Some special characters are unsafe in cookies |
| XML/JSON | Binary data can't go directly into text formats |
Base64 is NOT Encryption
This is a common misconception. Base64 is encoding, not encryption:
- It's completely reversible without any key
- Anyone who sees Base64 data can decode it instantly
- It provides zero security — it only changes the format
Do not use Base64 to hide passwords, API keys, or sensitive data.
Base64 Variants
| Variant | Difference | Use Case |
|---|
|---|---|---|
| Standard Base64 | Uses `+` and `/` | General purpose |
|---|---|---|
| URL-safe Base64 | Replaces `+` with `-`, `/` with `_` | URLs, JWTs |
| Base64 without padding | Omits trailing `=` | Some APIs prefer this |
Quick Examples
| Input | Base64 Output |
|---|
|---|---|
| `hello` | `aGVsbG8=` |
|---|---|
| `case converter` | `Y2FzZSBjb252ZXJ0ZXI=` |
| `12345` | `MTIzNDU=` |
Decoding Base64
Base64 decoding simply reverses the process. Use our free Base64 Encoder/Decoder tool to instantly convert text to Base64 or decode Base64 back to plain text — no setup required.