SVG to CSS Converter

Turn SVG into CSS, Tailwind, or a data URL

Settings

Apply as

Mask follows the text color. Background keeps the original colors.

Embedding format

Preview

Paste SVG to see the preview

Output
Paste SVG to see the generated code

What is SVG to CSS Converter?

SVG to CSS Converter turns SVG markup or an .svg file into CSS you can paste into a stylesheet. It generates CSS for backgrounds or masks, Tailwind classes, and data URLs.

The result and preview update as you type. Use it to embed small icons and background patterns in CSS without adding separate image files.

How to Use

  1. Paste SVG markup or load an .svg file. You can also drop a file.
  2. Choose how to apply the SVG and the embedding format.
  3. Choose an output format, then copy the generated code.

Main Settings

Application

  • Background: keeps the SVG's original colors and applies it with background-image. CSS cannot recolor it directly.
  • Mask: uses mask-image and currentColor to draw the SVG as a single-color silhouette. It follows the element's text color, which suits icons that need to change color with links or buttons. Multicolor SVGs become a single color.

When Mask is selected, you can choose the color used in the preview. It is not included in the output.

Embedding Format

  • URL encoding: percent-encodes special characters in the SVG. Keeps the content readable.
  • base64: encodes the SVG as base64. It can be shorter than URL encoding, but the content is not readable.

A data URL starts with data:image/svg+xml, for URL encoding and data:image/svg+xml;base64, for base64.

Output Formats

  • CSS: declarations that include repeat, size, and position for the background or mask. Paste it directly into a stylesheet.
  • Tailwind: the same result as Tailwind v4 utility classes.
  • data URL: the encoded string alone, for use in HTML src attributes or your own code.

Use Cases

  • Recoloring icons to match link or button text.
  • Inlining small background patterns in CSS without adding image files.
  • Preparing icons as Tailwind classes for a component library.
  • Turning an exported .svg file into a snippet you can paste into a stylesheet.

Things to Keep in Mind

  • A data URL is longer than the original SVG. base64 adds about a third, and URL encoding grows with special characters and non-ASCII text.
  • The output removes comments and metadata, adds a missing xmlns, and drops width and height when a viewBox is present. If you need the original SVG unchanged, keep a copy of the file before converting.