Skip to content
Run here 100% in your browser, no upload, no login

SVG to Data URI

Turn an SVG into a URL encoded or Base64 data URI and compare the byte size.

Both outputs point at the same image. URL encoding stays readable, base64 is safer inside quoted CSS values.

Paste an SVG document

Size comparison:

URL encoded data URI

Base64 data URI

CSS background usage

How to use it

  1. Paste a complete SVG document into the input box.
  2. Leave the whitespace option ticked to strip comments and collapse extra spaces before encoding.
  3. Press Convert. Both outputs appear at once and update on every edit.
  4. Compare the sizes shown under the input box, then copy the form that suits your situation.
  5. Copy the CSS block if you need a background-image rule with sizing already set.

Common use cases

Why it stays private

Encoding uses the browser encodeURIComponent and btoa functions on the text you paste. There is no upload, no account and no network request.

FAQ

Q: Which format is smaller? A: It depends on the source. Base64 grows every three bytes into four characters, while URL encoding only expands characters that are unsafe in a URL. The status line shows both sizes so you can pick by measurement rather than by habit.

Q: Why does the CSS block use the base64 form? A: Base64 uses no characters that need escaping inside a quoted CSS value, so it survives minifiers and preprocessors unchanged. The URL encoded form is fine too, but it contains percent signs that some tooling treats specially.

Q: Can I inline an SVG that contains a script? A: You can, but browsers do not run scripts inside an image context such as background-image or img. Scripts only run when the SVG is inline in the document, which is one reason to review any SVG you did not write yourself.

Your data stays on this device

SVG to Data URI runs 100% locally. Everything you paste or drop is processed by your own browser and never transmitted. Nothing is stored on our servers — close the tab and it is gone.

Nothing you type is sent to a server, logged, or used for analytics. The page works even with your network disconnected after first load.