Esta página aún no está traducida al español, así que la mostramos en inglés.

SVG to CSS Data URI Converter

Paste an SVG and get a compact, URL-encoded data URI plus ready-made background-image and recolorable mask-image CSS.

Actualizado el
Encoding
Open .svg
CSS output
Data URI
background-image
mask-image (recolorable icon)

background-image preview

mask-image preview

Tus datos nunca salen de tu ordenador. Todo se procesa localmente en tu navegador.

Cómo usar: SVG to CSS Converter

  1. Paste your SVG code, open an .svg file or load the sample.
  2. Keep Clean up SVG on to strip comments, metadata and editor attributes, and choose URL-encoded or Base64.
  3. Check both previews — the normal background image and the single-color mask version.
  4. Copy the data URI or the complete CSS rule and paste it into your stylesheet.

What is an SVG data URI?

A data URI embeds a file directly in your CSS instead of linking to it: background-image: url("data:image/svg+xml,…"). For small icons, dividers, patterns and custom checkboxes this saves an HTTP request, avoids a flash of missing images and keeps the asset next to the styles that use it.

URL-encoding vs Base64

SVG is text, so it doesn’t need Base64. Base64 inflates any file by about 33% and turns it into an unreadable blob that compresses poorly with gzip or Brotli. A URL-encoded SVG stays close to its original size and readable. Only a few characters must be escaped:

CharacterEncodedWhy
#%23Otherwise starts a URL fragment — colors like #fff break the image.
%%25The escape character itself.
< >%3C %3ERecommended for compatibility with strict parsers.
"' or %22Attribute quotes are switched to single quotes so the CSS can wrap the URI in double quotes.

Use Base64 only when a tool or framework rejects anything else. The size cards under the preview show both results so you can compare.

Recolorable icons with mask-image

An SVG used as a background image is rendered in isolation: CSS on the page can’t change its fills, and currentColor inside it won’t follow your text color. The mask-image snippet solves this by using the SVG only as a stencil and painting it with background-color: currentColor, so one icon works in any color, hover state or dark mode. The -webkit-mask line is still needed for some browsers.

Cleanup and limits

Cleanup removes the XML declaration, comments, <metadata>, <title> (meaningless in a background), Inkscape/Sodipodi/Sketch attributes and extra whitespace, and adds the required xmlns if it’s missing — without it the browser won’t render the image. Embed only small SVGs (a few KB): large data URIs bloat every CSS download and can’t be cached separately. For complex graphics, link the file instead. Need a React component rather than CSS? Use SVG to JSX; for raster images, see Image to Base64.

Using it in Webflow

Webflow’s Backgrounds panel expects an uploaded image, so paste the generated rule into a <style> tag in an Embed element or in the page/site custom code, and give your element the matching class (e.g. icon).

También se busca como: svg to css, svg data uri, svg to data url, url encode svg, svg background image, svg to base64, mask-image, inline svg css.

Herramientas que combinan con: SVG to CSS Converter

  • URL Encode / Decode — Percent-encode text for safe use in URLs, decode encoded strings back to readable text, and break any URL down into its parts and query parameters.
  • Codificación y descodificación Base64 — Convierte texto a Base64 y viceversa con compatibilidad total con UTF-8 (acentos, emojis), cambia a Base64 compatible con URL o arrastra un archivo para obtener su cadena Base64 o su URI de datos.
  • CSS Minifier — Paste a stylesheet to shrink it instantly.
  • CSS Animation Generator — Design CSS animations on a real keyframe timeline.

Preguntas frecuentes

Why isn’t my SVG data URI showing up?
The usual causes are an unescaped # (in colors like #fff), a missing xmlns="http://www.w3.org/2000/svg" attribute, or unbalanced quotes between the CSS url("…") and the SVG attributes. This tool fixes all three.
Is URL-encoding or Base64 better for SVG in CSS?
URL-encoding is usually better: the result is smaller, readable and compresses well. Base64 adds about a third to the size and is only worth it when a toolchain requires it.
Can I change the color of an SVG background image with CSS?
Not directly — CSS can’t reach inside a background image. Either edit the fill in the SVG before encoding, or use the mask-image snippet and set background-color, which you can change on hover or in dark mode.
Do I need to include charset=utf-8 in the data URI?
No. Non-ASCII characters are percent-encoded as UTF-8, which browsers decode correctly for SVG, so data:image/svg+xml, is enough.
Is there a size limit for data URIs in CSS?
Browsers handle very large data URIs, but they bloat your stylesheet and can’t be cached separately. Keep embedded SVGs to a few kilobytes and link larger files.
¿Puedo instalar SVG to CSS Converter como aplicación web y utilizarla sin conexión?
Sí. SVG to CSS Converter es una aplicación web instalable (PWA): se instala desde el navegador, no se descarga desde una tienda de aplicaciones. Haz clic en «Instalar aplicación» en la parte superior de esta página en Chrome o Edge (Windows, macOS, Linux, ChromeOS) o, en Android, utiliza «Compartir» → «Añadir a la pantalla de inicio» en iPhone y iPad, o «Archivo» → «Añadir al Dock» en Safari 17+ en un Mac. A continuación, se abrirá en su propia ventana con su propio icono y, como se ejecuta íntegramente en tu navegador, seguirá funcionando sin conexión. Firefox en el ordenador de sobremesa no permite instalar aplicaciones web. Cómo funciona la instalación.

Herramientas relacionadas