Skip to main content
🇪🇸 Español 🇧🇷 Português 🇩🇪 Deutsch
Image Converter Video Converter Audio Converter Document Converter
Tools Guides Formats Pricing API
Log In
Guide

Image to Base64: Embed Images in HTML, CSS, and JSON

PC By Pablo Cirre

Frequently Asked Questions

Below 4 KB embedding always wins: you save the HTTP request and the 33% overhead is negligible. Between 4–10 KB it depends on context (cache, HTTP/2). Above 10 KB embedding usually hurts: it breaks HTML/CSS cacheability and the browser cannot parallelize downloads. Rule of thumb: icons yes, photos no.

It works in webmail clients (Gmail web, Outlook web) but NOT in native clients: Outlook desktop has blocked data URIs by default since 2007 for security. The robust path for HTML email remains CID (Content-ID) inline attachments via multipart/related, or absolute URLs to hosted images. Use Base64 only in templates that will never be opened in Outlook desktop.

Yes — Base64 overhead is structural: every 3 binary bytes become 4 ASCII characters (+33%). The source format (PNG, JPG, WebP) does not change that. That is why optimizing to WebP/AVIF before encoding pays off — the 33% applies to a smaller binary, so the final string is much smaller.

Decoding itself is safe (just a re-encoding). The risk is what you decode: a Data URI can carry <code>image/svg+xml</code> with embedded JavaScript and trigger XSS if you render it inside the DOM. Always sanitize SVG with DOMPurify and never <code>innerHTML</code> Base64 without validating the real MIME type.

We use cookies and similar technologies to personalise content and ads, and to analyse traffic. Learn more about cookies.