How to use the Base64 decoder
- Paste a Base64 string to decode it, or type normal text to encode it. Auto-detect picks the direction for you.
- For encoding, tick URL-safe if the result will go in a URL or a token.
- Copy the result, or press Swap to convert it back and check it.
What is Base64?
Base64 is a way to write any data, including binary files, using only 64 safe characters: A–Z, a–z, 0–9, + and /. It exists because many systems, such as email and older web protocols, were designed for plain text and could corrupt raw binary data. Encoding the data as Base64 lets it travel through those systems unchanged.
How Base64 encoding works
The encoder takes the input three bytes (24 bits) at a time and splits them into four groups of 6 bits. Each 6-bit number, from 0 to 63, picks one character from the Base64 alphabet. For example, the word Man:
| Step | M | a | n |
|---|---|---|---|
| ASCII | 77 | 97 | 110 |
| Bits | 01001101 | 01100001 | 01101110 |
Regrouped into 6-bit chunks this gives 010011 010110 000101 101110 = 19, 22, 5, 46, which are the characters T W F u. So Man becomes TWFu. Because 3 bytes become 4 characters, Base64 makes data about 33% larger.
Examples
| Text | Base64 |
|---|---|
| Hello | SGVsbG8= |
| Hello, World! | SGVsbG8sIFdvcmxkIQ== |
| user:password | dXNlcjpwYXNzd29yZA== |
| café | Y2Fmw6k= |
Where you will see Base64
- Email attachments, which are sent as Base64 inside the message.
- Data URLs such as
data:image/png;base64,…that embed small images in web pages. - JSON Web Tokens used for logins, whose header and payload are URL-safe Base64.
- HTTP Basic authentication, which sends
user:passwordas Base64. That is why it must only be used over HTTPS.