SVG to CSS url()
Paste an SVG and get a data URI for background-image — compact URL-encoding that’s smaller than base64, plus copy-ready CSS and HTML.
SVG code
Paste SVG code above, or open an .svg file.
Preview as a CSS background
Ready to copy
Why URL-encode instead of base64?
SVG is text, so it can sit in a data URI almost as-is: only a few characters (like #, < and %) need escaping. That’s usually around a third smaller than base64, stays readable, and compresses better with gzip. Base64 is there for tools that insist on it.
Good to know
- Comments, line breaks and extra spaces are removed, and a missing
xmlnsis added — browsers need it in data URIs. - Want a file instead? SVG Code to File downloads it as SVG, PNG, JPG or WebP.
Frequently asked questions
What is an SVG data URI?
A way to put an SVG straight into CSS, for example as a background-image, without a separate file: url("data:image/svg+xml,…").
Why URL-encode instead of base64?
SVG is text, so only a few characters (such as #, < and %) need escaping. That is usually about a third smaller than base64, stays readable and compresses better with gzip. Base64 is available for tools that require it.
What does Squozi change in my SVG?
Comments, line breaks and extra spaces are removed, and a missing xmlns attribute is added, because browsers need it in data URIs.
Is my SVG uploaded?
No. The conversion happens in your browser.
I need a file, not CSS. What should I use?
SVG Code to File downloads SVG code as an .svg, PNG, JPG or WebP file.