Base64 Explained: What It Is and When to Use It
If you have ever seen a long string like SGVsbG8gV29ybGQ= in a web address, an email or a config file, you have met Base64.
What Base64 is
Base64 is a way to represent any data, such as an image or a file, using only 64 safe text characters (letters, digits, plus and slash). Many systems, including older email protocols and some data formats, only handle plain text reliably. Base64 lets binary data travel through them without being corrupted.
What it is not
Base64 is not encryption. Anyone can decode it instantly. Never use it to hide passwords or secrets. It is only a format change, and it makes data about one third larger.
Common uses
- Embedding small images directly in HTML or CSS as a data URI, saving a network request for tiny icons.
- Email attachments, which are encoded this way behind the scenes.
- HTTP basic authentication headers, where "username:password" is Base64-encoded (this is why such connections must always use HTTPS).
- JWT tokens, whose readable parts are Base64-style encoded; you can inspect them with the JWT Decoder.
Encoding and decoding
Use Base64 Encode / Decode for text. For pictures, Image to Base64 produces a data URI you can paste into code and Base64 Image Viewer turns an encoded string back into an image so you can check it.
Related encodings
URLs have their own rules for special characters; use URL Encode / Decode for those. For general text conversions, see Text Encoder / Decoder.
When not to use it
- For large images on a website; normal image files are cached and smaller.
- As a security measure; use real encryption instead.
Frequently asked questions
Why does Base64 end with equals signs?
The equals signs are padding. Base64 works on groups of three bytes, and padding fills the final group when the data does not divide evenly.
Why is the Base64 version bigger?
Every three bytes of input become four characters of output, so the encoded text is about 33 percent larger.
Is a Base64 image slower than a normal image?
Often yes for large images, because it cannot be cached separately and increases the size of the page itself. It is best for tiny icons.
What is URL-safe Base64?
A variant that replaces plus and slash with minus and underscore so the result can be used inside web addresses without further escaping.
Key takeaways
- Base64 is encoding, not encryption.
- It makes data about a third bigger.
- Use it for small embedded assets and data transport.