Text or files, standard or URL-safe, with UTF-8 handled properly — which is where most quick implementations quietly break.
Produces a data: URI you can paste straight into CSS or an <img>.
Why UTF-8 needs saying. btoa() only accepts characters below
U+0100 and throws on anything else — so the usual one-liner breaks the moment someone types
ação or an emoji. This encodes the text to UTF-8 bytes first, which is what every
other system means by "base64 of this string".
Base64 is not encryption. It is a way of carrying bytes through
text-only channels, and anyone can reverse it in one step — this page does it with no key.
Never use it to hide a secret.
Data URIs grow by about a third. A 90 kB image becomes roughly 120 kB of
text, and it cannot be cached separately from the page that carries it. Worth it for a
small icon, rarely worth it for a photo.