Skip to main content

InstrumentsSVG to CSS Data URI

SVG to CSS Data URI

Turn an SVG into a CSS background-image data URI, URL-encoded or base64, with the byte count and a preview.

All tools

SVG to CSS Data URI

This tool does not sanitise SVG. It refuses a short list of constructs: script elements, foreignObject, event attributes such as onload, DOCTYPE and entity declarations. SVG from untrusted sources should be cleaned before use, and the output is not a guarantee that the SVG is safe.

Paste the full SVG document. Up to 2 MB (2,097,152 characters). The text stays in this page and is not written to the URL.

Encoded keeps the markup readable inside the CSS. Base64 has no escaping rules but is about a third larger.

Input is 140 bytes in UTF-8.

Preview: the generated data URI tiled at its natural size. It is not a full render of the SVG.

CSS
background-image: url("data:image/svg+xml,%3Csvg xmlns=%22http://www.w3.org/2000/svg%22 width=%2224%22 height=%2224%22 viewBox=%220 0 24 24%22%3E %3Ccircle cx=%2212%22 cy=%2212%22 r=%2210%22 fill=%22%231a1a1a%22/%3E %3C/svg%3E");

FAQ

Does the tool make my SVG safe to use?

No. The tool does not sanitise SVG. It refuses a short list of constructs, such as script elements, foreignObject, event attributes and DOCTYPE or entity declarations. Clean SVG from untrusted sources before you convert it.

Why does the tool reject an SVG that looks harmless?

The checks look for specific text, so a file that contains one of the listed constructs is refused even when the use is harmless. Remove that element or attribute, then convert the file again.

Should I use encoded or base64 mode?

Encoded mode keeps the markup readable inside the CSS. Base64 has no escaping rules, but its output is about a third larger than the input.

  1. 01Web Image Architecture: AVIF, WebP & Responsive PatternsTutorial
  2. 02Frontend Performance Architecture: Optimization PatternsTutorial

Personalize your path

Choose your experience level once.

Next Step

Build fundamentals after each tool run so you can apply concepts with confidence.

Get new tool alerts

Receive updates when new tools are published.

RSS feed