What Is Base64 Encoding?
Last updated 2026-09-11
Base64 is a way of representing binary data as plain ASCII text — useful whenever a system can only safely handle text, not raw bytes.
Understand the goal
Some systems (email, URLs, JSON, older text protocols) can't reliably carry arbitrary binary data. Base64 converts that binary data into a text-safe representation.
See how it works conceptually
Base64 takes data in groups of 3 bytes (24 bits) and re-encodes them as 4 characters from a 64-character alphabet (A–Z, a–z, 0–9, +, /), padding with = when the input doesn't divide evenly.
Know when it's used
Common uses: embedding small images directly in HTML/CSS as data URIs, encoding attachments in email (MIME), and encoding the header/payload of a JWT.
Example
The text "hello" encodes to "aGVsbG8=" in Base64.
Important Considerations
- Base64 is an encoding, not encryption — anyone can decode it instantly. Never use it to protect sensitive data.
- Base64-encoded data is about 33% larger than the original binary data, due to the 3-bytes-to-4-characters expansion.
Frequently Asked Questions
- Is Base64 secure?
- No — it provides no confidentiality at all. It's purely a format conversion; decoding it requires no key or password.
- Why does Base64 output sometimes end with = signs?
- The = characters are padding, used when the input length isn't a multiple of 3 bytes, so the output can still be split into complete 4-character groups.