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.