Base64 for your stack
Reference patterns and copy-ready snippets for working with Base64 and data URIs in HTML, CSS, and JavaScript — without a single byte leaving the browser.
Inline assets without a request
A data URI packs a file directly into a URL. It’s ideal for tiny, frequently used assets where an extra HTTP round trip costs more than the added bytes.
Best for small assets
Icons, spinners, and UI sprites under a few KB benefit most.
Mind the size
Encoded data is ~33% larger, so large images are better served as files.
Background images, inline
Embed an encoded image straight into a stylesheet. SVG is especially efficient as a data URI because the markup compresses well.
Generate a snippetStandard vs URL-safe
Two common Base64 alphabets exist. Pick the one that matches where the string is headed.
Standard
Uses + and /, with = padding. The default for most APIs, email, and file encoding.
URL-safe
Swaps + and / for - and _ so the string is safe in URLs and filenames.
Bring Base64 into your build
The interactive generators and validators are coming next. In the meantime, explore the categories and guides.