Guides / Base64
What Is Base64 and When Should You Use It?
Base64 is a way to write binary data using only plain text characters. You will see it in email attachments, data URLs and API tokens.
How Base64 works
Computers store data as bytes. Some places, such as email bodies, JSON fields and URLs, are designed for text and can break on raw bytes. Base64 solves this by taking every three bytes (24 bits), splitting them into four groups of six bits, and mapping each group to one of 64 safe characters: A to Z, a to z, 0 to 9, plus + and /. Padding with = fills out the end.
Why the output is bigger
Every three input bytes become four output characters. Base64 data is therefore about 33 percent larger than the original. This is the main trade-off. It is fine for small icons or tokens, but it is wasteful for large files.
Where you will see it
- Data URLs: small images embedded directly in HTML or CSS, such as
data:image/png;base64,.... - Email attachments: the MIME standard encodes attachments in Base64.
- API credentials: HTTP Basic authentication encodes
username:passwordin Base64. - JSON or XML payloads: binary content is often carried as a Base64 string.
Base64 is not encryption
Base64 is an encoding, not a security measure. Anyone can decode it instantly. Never rely on it to hide passwords or private information.
Try it yourself
Use the Base64 Encoder to encode text or decode a string. It handles UTF-8, so accented letters and emoji round-trip correctly. The work happens in your browser.