Skip to main content
Back to Tools

SVG to Data URI

Convert SVG to a base64 or utf8 data URI.

Input

Drag & drop SVG

Drop a .svg file here, click to browse, or paste raw markup below.

input.svg

Output

Result will appear here

Browser-local SVG Processing

The SVG to Data URI utility processes SVG content in your browser. The raw SVG is not uploaded for processing; actual processing time depends on the file and your device. See the Privacy Policy for normal website requests and hosting logs.

About SVG to Data URI

Inline vector assets in stylesheets eliminate additional HTTP network requests during page load. This converter compiles SVG markup into format-ready URI strings (either Base64 or UTF-8 URL-encoded), which can be directly embedded in CSS `background-image` properties or HTML `src` links. UTF-8 encoding keeps text payload compact while preserving vector readability.

How It Works

01

Paste your SVG code.

02

Select either UTF-8 or Base64 encoding based on your stylesheet guidelines.

03

Copy the compiled CSS background code snippet and paste it into your styles.

Data URI notes

Generate a CSS- or HTML-ready Data URI when a small SVG needs to travel inside a stylesheet, inline style, or attribute. Compare URL-encoded XML with Base64 in the destination build because the most maintainable representation depends on your pipeline.

What this tool does

  • Encodes SVG markup as a Data URI using the selected UTF-8 or Base64 mode.
  • Escapes characters that would otherwise conflict with a URL, CSS declaration, or HTML attribute.
  • Returns a copyable value that can be tested in a real CSS background-image or image source.

Review before publishing

  • Inlining removes a separate request but increases the size of the containing HTML or CSS and can reduce independent caching.
  • Escaping can be changed by CSS preprocessors or templating systems, so test the emitted output.
  • Do not embed untrusted SVG without applying an application-appropriate security policy.

SVG input

<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 10'><circle cx='5' cy='5' r='4'/></svg>

URL-encoded CSS value (illustrative)

url("data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2010%2010'%3E...")

Frequently Asked Questions

Should I use UTF-8 or Base64 for SVG data URIs?

UTF-8 URL-encoded strings are often compact for text-based SVGs and remain readable, while Base64 can be convenient for opaque payloads. Compare the output size and compatibility with your build pipeline.

How do I use this in CSS?

You can paste the generated code directly as the value of a CSS background: `url('data:image/svg+xml;utf8,...')`.

Are data URIs good for website loading performance?

Inlining small SVG icons as data URIs can remove a separate asset request, but it also increases the size of the HTML or stylesheet. Compare the trade-offs for your page.

Related Vector Utilities

View all 39 tools