Base64 Image Data-URI Injector
Drop an image file and instantly generate an inline CSS background-image rule using a Base64 Data-URI. Zero uploads, 100% private.
data:[type];base64,[data]. Data-URIs eliminate the need for a separate file download.image/png or image/svg+xml. Browsers use MIME types to handle data correctly. The MIME type is the prefix of every Data-URI string.readAsDataURL() to convert dropped images.The Complete Guide to Base64 Data-URIs in CSS
Inlining images directly into your stylesheet is a powerful but often misunderstood technique. This guide explains exactly what Base64 encoding does, when it helps, when it hurts, and how to use this tool to get the output you need instantly.
How to Use This Tool
background-size, background-repeat, and background-position values you need. The output updates in real time.How Base64 Encoding Works Under the Hood
Every image file on your hard drive is stored as raw binary data - a sequence of bytes, each with a value from 0 to 255. Many of these byte values correspond to characters that have special meaning in text formats (quotes, angle brackets, null bytes), making it impossible to paste binary data directly into a CSS file without corrupting the parser.
Base64 solves this by mapping every possible group of 3 bytes to exactly 4 characters drawn from a safe alphabet of 64 printable symbols: uppercase A-Z, lowercase a-z, digits 0-9, plus (+), and forward slash (/). The result is a string that looks like iVBORw0KGgo... - completely safe to place anywhere a text string is accepted. The browser reverses the mapping when it encounters the Data-URI, reconstructing the original binary image in memory.
The 33% size increase is not a bug or an inefficiency of a particular algorithm - it is a mathematical certainty. 3 input bytes become 4 output characters always. If your source PNG is 30KB, the Base64 string will be approximately 40KB, and your CSS file grows by that exact amount.
When Inlining Makes Sense
The tradeoff is straightforward: inlining removes one HTTP request in exchange for making the parent file larger. This is a good deal only when the request overhead is larger than the size penalty. In practice, this favors small, critical-path assets: a tiny favicon embedded in your main CSS loads with zero extra round trips on every page. A small SVG icon set bundled into a component stylesheet is another legitimate case, particularly in single-page applications where the CSS is already being code-split per route and cached aggressively.
HTTP/2 and HTTP/3 have reduced the per-request overhead that once made inlining attractive. On a modern HTTP/2 server, multiplexed connections mean dozens of small files can be fetched simultaneously with almost no per-file cost. This shifts the math against inlining for all but the smallest assets. If your deployment uses HTTP/2 (which virtually all modern hosting providers do), be conservative: keep Base64-inlined images under 5KB in their original form.
The Render-Blocking Warning
CSS linked in the HTML head is render-blocking. The browser cannot display any content on screen until every byte of every linked stylesheet has been downloaded, parsed, and applied. When you embed a large Base64 image inside a render-blocking stylesheet, you force every visitor to download that image data before seeing anything on the page - even if the image is below the fold and not yet visible. This directly increases your Largest Contentful Paint (LCP) score, which is a Core Web Vital Google uses for search rankings. The 50KB recommendation in the upload zone is a conservative practical limit that avoids meaningful LCP regression on typical connections.
Frequently Asked Questions
src or url() reference) is almost always faster: the browser can cache it independently, download it in parallel, and reuse it across pages without re-downloading. A good rule of thumb: if the Base64 string pushes your CSS file past 10KB from a single asset, link it instead. SVG icons embedded in CSS are a common legitimate use case, as their source is already text and the Base64 overhead is minimal.SVGs: The Best Candidate for Inlining
SVG files deserve special mention. Because SVG is already a text format (XML), you can embed it in CSS either as a Base64 string or as a URL-encoded raw SVG string (using url("data:image/svg+xml,%3Csvg...")). The URL-encoded approach avoids the 33% size increase entirely and produces a string that is still human-readable and editable. For SVG icons and simple illustrations, URL-encoding instead of Base64-encoding can be meaningfully more efficient. The tradeoff is that URL encoding is slightly more complex to generate and some older CSS preprocessors have length limits on unencoded strings. This tool uses Base64 for universal compatibility across all image types.