Skip to content
Toolwright

SVG to Data URI

SVG to Data URI converts an SVG into a data URI for CSS backgrounds, masks, img tags and Markdown. The URL-encoded form is usually much smaller than Base64. It runs in your browser, so your file is never uploaded.

Tool 108 · Developer
Outside requests …How to checkRuns on this deviceWorks offline once opened

How to use SVG to Data URI

  1. Paste your SVG or drop the file.
  2. Pick CSS background, mask, img tag, Markdown or just the URI.
  3. Copy the result into your stylesheet or HTML.

Frequently asked questions

Why is URL-encoded smaller than Base64?

Base64 makes every file about a third bigger. An SVG is already text, so only a few characters need escaping, which adds far less. Use Base64 only for tools that cannot read the plain form.

Is my SVG uploaded?

No. The conversion happens in your browser.

Can I change the colour of an SVG used as a CSS background?

No, an SVG used as a background or img cannot take colour from CSS. Use the mask option with a background colour instead, or put the SVG inline in the page.

What does it change in my SVG?

It adds the SVG namespace if missing, removes comments and the XML declaration, switches attributes to single quotes, and tidies whitespace so the string is as short as it can be.

Next step

Smaller input gives a smaller URI. Optimize the SVG first. Open SVG Optimizer.

  1. 110

    SVG Optimizer

  2. 116

    SVG to React

  3. 050

    Image to Base64 & Data URI

  4. 004

    Base64 Encode & Decode