Converters

SVG to CSS Converter

Paste an SVG and get a CSS background-image rule with the SVG as a data URI. The SVG is URL-encoded (not Base64) which produces smaller output and preserves crisp scaling. The output is a ready-to-paste CSS rule like background-image: url("data:image/svg+xml,..."). Great for inline icons and decorative SVGs in CSS.

SVG to CSS — Turn an SVG into a CSS background-image data-URI snippet

What it does

  • Converts SVG markup to a CSS background-image data URI
  • Uses URL encoding (not Base64) for smaller output and crisp rendering
  • Outputs a complete CSS rule ready to paste into a stylesheet
  • Preserves SVG gradients, filters, and animations in the data URI
  • Handles multi-line SVG input

Use cases

  • Embedding SVG icons as CSS background images without external files
  • Creating decorative CSS backgrounds from SVG patterns
  • Inlining SVG logos in email templates or CSS-only components
  • Reducing HTTP requests by embedding small SVGs directly in CSS

How it works

1

Paste your SVG markup into the input pane

2

The tool URL-encodes the SVG and wraps it in a data URI

3

The output is a CSS background-image rule

4

Copy the CSS rule into your stylesheet

Frequently asked questions

1Why URL encoding instead of Base64?

URL-encoded SVGs are typically 10-20% smaller than Base64 versions, and they preserve the SVG's text-based nature so it can be read and debugged. Base64 is only necessary for very old browsers or when the SVG contains characters that break URL encoding.

2Does it work with SVGs that use external references?

SVGs with external references (like <use href="file.svg#id">) won't work as data URIs because the external file isn't embedded. The SVG needs to be self-contained — all gradients, filters, and patterns defined inline.

3Can I use this for SVG sprites?

For SVG sprites, you're better off using an inline SVG with <symbol> elements and referencing them with <use>. This tool is for embedding a single SVG as a CSS background.

Related tools

Use SVG to CSS offline in Devinity

All 95 tools run locally on your Mac. No internet required, no data sent to servers.

Download Devinity →