SVG to CSS Data URI Converter

Convert SVG markup to a URL-encoded data URI and a ready-to-paste CSS background-image rule. Runs locally in your browser.

About this tool

Inline SVG data URIs avoid an extra HTTP request. This tool collapses whitespace, switches double quotes to single quotes, adds the SVG namespace if missing and percent-encodes the characters that break CSS urls. URL-encoding is usually smaller than base64 for SVG. Nothing is uploaded.

Related: JSON Formatter & Validator · Base64 Encode & Decode · URL Encoder & Decoder · SHA-256 / SHA-1 Hash Generator · Unix Timestamp Converter

Frequently asked questions

Why use an SVG data URI?

It inlines small icons in CSS, saving an HTTP request.

Why encode instead of base64?

URL-encoded SVG is usually smaller than base64 and stays readable.

What size is reasonable?

Keep inline images under a few KB; larger files are better as separate cached files.