SVG to CSS

Turn SVG markup into a paste-ready CSS icon.

Apply as
MaskBackground

Mask recolors with the text color. Background keeps the original colors.

Encoding
URL-encodedbase64

Preview

Paste SVG markup to see the preview

Output
CSSTailwindData URL

Paste SVG markup to see the result

What is SVG to CSS?#

SVG to CSS turns SVG markup into CSS you can paste into a stylesheet. Apply the SVG as a mask or a background, then copy the result as CSS declarations, Tailwind classes, or a data URL.

Paste the markup or load an .svg file, and the output updates as you work. Everything runs in your browser, so your markup never leaves your device.

How to Use#

  1. Paste SVG markup, or load an .svg file.
  2. Choose how to apply the SVG (mask or background) and how to encode the data URL (URL-encoded or base64).
  3. Pick the output format (CSS, Tailwind, or data URL), then copy the result.

The preview shows the SVG at three sizes on a checkerboard. When a mask is selected, the color control changes the preview only.

Mask or Background#

  • Mask: paints the SVG as a single-color silhouette using currentColor, so it follows the element's text color. Suits icons that need color variations.
  • Background: draws the SVG with its own colors through background-image. Its colors cannot be changed from CSS.

Output Formats#

  • CSS: ready-to-paste declarations, including repeat, size, and position.
  • Tailwind: the same result as utility classes, using arbitrary values for the data URL.
  • Data URL: the encoded data:image/svg+xml,... string on its own, for use in your own code.

The data URL is URL-encoded by default. Switch to base64 to pack the content uniformly.

Common Use Cases#

  • Turning a logo or pictogram into a CSS mask that matches link or button colors.
  • Inlining a small SVG background without adding an image file to the project.
  • Preparing Tailwind-ready classes for a component library.
  • Converting an exported .svg file into a paste-ready snippet for a stylesheet.

FAQ#

Notes#

  • A data URL grows the markup: base64 adds about a third, and URL-encoding expands special characters. Large SVGs produce long outputs.
  • Converter

Last updated:

Related tools