Base64 represents arbitrary binary data using 64 printable characters. It exists because a great deal of infrastructure was built assuming text, and binary data pushed through it gets corrupted. It provides no secrecy of any kind.
It is not encryption, and treating it as such is a real bug
Base64 requires no key, so anyone can reverse it instantly. A password, API key or personal detail that is merely Base64 encoded is, for every practical purpose, stored in plain text. This turns up in production code often enough to be worth stating plainly.
It is not compression either. Base64 represents three bytes using four characters, so encoded data is roughly 33% larger than the original, before any padding.
The URL-safe variant
Standard Base64 uses + and /, both of which mean something else in a URL, plus = padding that is awkward in a query string. The URL-safe variant substitutes - and _ and usually drops the padding entirely.
JSON Web Tokens use this variant, which is why a JWT never contains a plus or a slash. Decoding URL-safe data with a standard decoder produces garbage or an error, and it is a common cause of a token that 'looks fine' but will not parse.
When a data URI is worth it
Embedding an image as a data: URI removes a network request, which can be worth it for a tiny icon that appears on every page. Beyond that it is usually a loss.
The data is a third larger, it cannot be cached separately from the document that contains it, and it inflates the HTML or CSS that must arrive before anything renders. A small file fetched in parallel usually beats a large document that blocks.
In short
Use Base64 to move binary data through text-only channels, never to hide anything. Match the alphabet to the destination, and reach for data URIs only when the file is genuinely tiny.
Base64 Encoder and Decoder
Encode and decode Base64, including UTF-8 text, URL-safe output, and files or images as data URIs.
Keep reading
UUID v4 vs v7: which one belongs in your database?
Random UUIDs scatter writes across an index. Time-ordered v7 fixes that, at the cost of revealing creation time — how to choose between them.
What makes a password strong (it isn't the symbols)
Why length beats complexity, what entropy in bits actually measures, and why the old advice about special characters made passwords worse.
MD5, SHA-1, SHA-256: which hash should you actually use?
What it means for a hash to be broken, why fast hashes are the wrong tool for passwords, and how to verify a downloaded file properly.