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.
How to use SVG to Data URI
- Paste your SVG or drop the file.
- Pick CSS background, mask, img tag, Markdown or just the URI.
- 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.
Related tools
- 116