A small icon inside the stylesheet saves a whole request, and more importantly it saves the moment where the page is already visible but the icons are not there yet. This hands the SVG back already wrapped in the rule you have to paste.
The encoding is percent, not base64. An SVG is text: base64 makes it a third bigger in exchange for nothing. Only the characters that would break a url() are escaped, which keeps the result short and still readable.
How to use it
- Add the icons.
- Pick a rule, a CSS variable, an <img> tag or just the data URI.
- Process, and paste the result into your stylesheet.
Frequently asked questions
- When is it worth it and when not?
- Under about 3 kB, almost always. Above that, the data URI travels inside the CSS on every load and can no longer be cached separately: a separate file is the better trade.
- Can I change its colour from CSS?
- Only where it is a background or a mask. A data URI in background-image is an image, and currentColor does not reach inside it. To paint it with CSS, use a sprite with <use>, or mask-image.
- Why are the quotes single inside?
- Because the rule uses double ones outside. Swapping the inner ones is the shortest way to avoid escaping anything else.
Related tools
Optimise SVGSVGO in the browser: drops editor metadata and rounds paths.
SVG to PNGRasterise at any size, on a transparent or solid background.
SVG to PDFA one-page PDF at the drawing’s real size.
SVG spriteA whole icon set in one file, ready for <use>.
Recolour SVGChange a whole set’s colours without opening them one by one.