Convert an SVG into a CSS background-image you can paste straight into a stylesheet. The SVG is optimized, then URL-encoded — usually smaller and more compressible than Base64 — and both versions are shown with their sizes and a live preview. Choose single or double quotes, and drop in a file or paste the markup. It's free, runs in your browser, and nothing is uploaded.
| Character | Becomes |
|---|---|
| " | ' (swapped) |
| # | %23 |
| % | %25 |
| < | %3C |
| > | %3E |
| { } | %7B %7D |
URL-encoded, in most cases. It's smaller and compresses better; Base64 is only needed for very old tools.
Usually an unescaped # (in a color) or a double quote clashing with the url() quotes. This tool escapes both.
Not as a background-image. Use it as mask-image with background-color: currentColor instead.
Yes. Editors add comments and metadata that cost bytes in every CSS file that uses the icon.
No. Conversion happens in your browser.
An SVG can be used in CSS as a data URI in two ways. Base64 always works but grows the markup by a third and compresses poorly. URL-encoding is usually smaller: whitespace is collapsed, double quotes are swapped for single quotes, and only the characters that would otherwise break the URL — %, #, <, >, { and } — are percent-escaped, leaving the rest readable. The converter does that minimal encoding rather than encodeURIComponent, which escapes far more than necessary. Before encoding it can optimize the SVG with the site's own optimizer, removing comments, editor metadata and excess precision. The output is wrapped in url() with your choice of quote character, and any of that character inside the data is escaped so the rule stays valid. A preview renders the result as a background, and both sizes are compared. For icons that should take the text color, the page notes the mask-image technique.