Encoding an image as a Base64 string
Choose an image and this tool converts it into a Base64-encoded data URL you can paste directly into CSS (background-image: url(...)), HTML (<img src="...">), or JSON payloads - useful for embedding small images without a separate file request. Everything happens locally in your browser; your image is never uploaded.
When embedding beats a separate file request
Every linked image file normally means a separate HTTP request before it can display - for very small icons or images, especially ones that appear repeatedly across a page (like a sprite or inline logo), embedding the image directly into the HTML or CSS as Base64 can eliminate that extra round trip entirely, which matters more on pages with many small images than on pages with just one or two.
Why the encoded text is roughly a third larger
Base64 represents arbitrary binary data using only 64 safe, printable characters, and that encoding scheme inherently expands the data by about 33% compared to the original binary file size - a real tradeoff against the saved HTTP request, which is why Base64 embedding makes sense for small images but becomes a net loss for larger ones.
Where embedded images commonly get used
Email templates (where external images are often blocked or stripped by email clients), small UI icons bundled directly into a CSS file, and self-contained single-file HTML documents that need to work without any external file dependencies are the most common legitimate uses for this kind of embedding.
Using the output in CSS and HTML
The result is a complete data URL, so you can drop it straight into the places that expect an image address. In a stylesheet it goes inside url() for a background-image, and in HTML it goes into the src attribute of an img tag. Either way the browser draws the picture without making a separate request, which is handy for single-file pages, HTML emails, and small interface icons that must appear instantly.
The caching trade-off to keep in mind
A linked image file is downloaded once and then reused from the browser cache on every later page. An image embedded in the HTML is downloaded again with every page view, because it is part of the document itself. Embedding in a shared stylesheet is a middle path, since the whole stylesheet is cached. For anything larger than a small icon, a normal file with long-lived caching is almost always faster.
Prepare the image before you encode it
Because Base64 makes the data about a third larger, shrink the picture first. Resize it to the exact display size, compress it with an image optimizer, and consider a modern format such as WebP when your audience's browsers support it. SVG graphics are already text, so they can usually be pasted inline without Base64 at all, and often come out smaller that way.