SVG to CSS

Convert SVG markup into an optimized CSS background-image data URI, URL-encoded or Base64, with a live preview. Free online SVG to CSS tool.

About this tool

Turn SVG markup into a CSS background-image data URI. URL encoding keeps the result short and readable; Base64 is also available.

How to use

  1. Paste your SVG.
  2. Choose URL-encoded or Base64.
  3. Copy the CSS declaration and check the preview.

Frequently asked questions

URL-encoded or Base64?

URL-encoded SVG is usually smaller and stays readable. Base64 is safer in tools that mishandle special characters.

Why was xmlns added?

SVG used as a data URI needs xmlns="http://www.w3.org/2000/svg" to render, so it is added when missing.

Is whitespace removed?

Yes. Line breaks and extra spaces between tags are collapsed to shorten the result.

Related tools