SVG to CSS Data URI
Convert SVG markup into an optimized CSS data URI — URL-encoded or base64, minified, with live preview and size readout.
Tool input is processed locally in your browser and is not submitted to CodeNimbleTools. Avoid pasting production secrets into any device or website you do not fully trust.
About this tool
Inlining small SVGs as CSS data URIs kills an HTTP request per icon and keeps styling self-contained. This converter minifies your SVG and encodes it correctly — URL-encoding (smaller and debuggable) or base64 — wrapped in a ready-to-paste background-image rule.
A checkered live preview shows the result, and a byte counter helps you keep URIs sensible.
How to use it
- Paste your SVG markup (a missing xmlns is added automatically).
- Choose URL-encoding (recommended) or base64, and your quote style.
- Copy the generated CSS class.
- Check the preview and size readout before shipping.
Useful ways to apply it
- Inlining UI icons without an icon font or sprite sheet.
- Custom list bullets and form control graphics in pure CSS.
- Email-safe decorative graphics where external images are blocked.
- Eliminating tiny-image HTTP requests on performance-critical pages.
Worked example
Example input
<svg xmlns="http://www.w3.org/2000/svg"><circle cx="5" cy="5" r="4"/></svg>
Expected output
url("data:image/svg+xml,...")
Edge cases to check
- Quotes, hashes, whitespace and non-ASCII text need correct encoding.
- Untrusted SVG can contain active or external content depending on how it is embedded.
- Very large data URIs hurt readability and caching.
Known limitations
Use trusted SVG input and test the generated URI in the exact CSS context where it will be deployed.
How this tool was reviewed
Reviewed with quotes, hashes, whitespace and xmlns handling.
Standards and technical references
See the site-wide testing methodology for fixture categories, privacy checks and correction policy.
Frequently asked questions
URL-encoding or base64 — which is better?
Why does my SVG need xmlns?
Is there a size limit?
Privacy
Tool input is processed locally in your browser and is not submitted to CodeNimbleTools. Avoid pasting production secrets into any device or website you do not fully trust.