Convert images to Base64 data URIs for embedding in HTML and CSS. Free online tool — no signup required.
Convert images to Base64 data URIs for embedding in code.
Drop your image here
Encode any image as a Base64 string or a complete data URI ready to paste into HTML, CSS, JavaScript, JSON payloads, or markdown. The encoder runs entirely in your browser, supports JPG, PNG, WebP, AVIF, GIF, and SVG, and outputs both the raw Base64 string and the full `data:image/...;base64,...` URI you can drop straight into a `src=""` or `background-image: url()` declaration. Useful for inlining small icons to eliminate HTTP requests, embedding hero images in email templates that don't reliably reach external assets, and stuffing avatar previews into JSON API responses.
Inline images as Base64 when the asset is small (under 2-4 KB), critical above-the-fold, and only used on a single page — typical examples are sprite-style UI icons, the inline logo in an HTML email, or signature images in an automated PDF report. Avoid Base64 for anything large or shared across pages: every byte expands by roughly 33%, the encoded blob defeats browser caching, and large data URIs measurably hurt parse time. For most modern web work, you should use SVG icons or HTTP-cached PNG/WebP assets first and reach for Base64 only in the specific contexts above.
Upload an image
Drop any image file. Smaller is better — ideal Base64 candidates are under a few KB.
Choose output style
Pick 'Data URI' for ready-to-paste use in HTML/CSS, or 'Raw Base64' if you'll prefix the MIME type yourself in code.
Copy the encoded string
Click copy to put the encoded value on your clipboard. Long strings are line-wrapped on display only; copy preserves the original format.
Paste into your code
Drop the data URI directly into an HTML img src, CSS background-image url(), or wherever your tooling expects an image reference.
Your images are processed entirely in your browser. They are never uploaded to any server. Once you close the tab, all data is gone. No tracking, no storage, no cookies for your files.
No. Base64 is encoding, not encryption — anyone can decode the string back to the original image. It exists to safely transport binary data inside text-based formats like JSON, XML, or HTML.
Base64 represents 3 binary bytes as 4 ASCII characters, an inherent 33% size expansion. There is no way around this; it's mathematical.
Yes. Any Base64 decoder, including most browsers and online tools, can reverse the encoding back to the original binary.
Almost always, yes. SVG markup is shorter than the Base64 of the equivalent rasterized PNG and scales perfectly. Use Base64 only when you need a raster image specifically.
Yes. The full multi-frame file is encoded. Note that animated GIFs are large; consider GIF to MP4 first if size matters.