Skip to content

SVG to Base64 converter

Convert an SVG into a Base64 data URI to embed directly in your CSS or HTML.

SVG code (source)
SVG Preview Preview unavailable (invalid SVG) Visual preview
{{ errorMsg }}
CSS Background-Image
Pure Base64 string
HTML <img> tag

Why encode an SVG as Base64?

The SVG (Scalable Vector Graphics) is an XML-based vector image format. It has the huge advantage of being infinitely scalable without ever losing quality. However, if your website loads dozens of small .svg files (such as social media icons or arrows), this generates many HTTP requests that slow down page loading.

Converting your SVG code to a Data URI Base64 lets you embed the image directly inside your CSS or HTML file. The browser no longer needs to query the server to fetch the image; it loads instantly with the rest of the code.

Data URI vs. Base64

A pure Base64 string looks like PHN2ZyB4.... For the browser to understand it is an SVG image, a prefix called a Data URI must be added: data:image/svg+xml;base64,.

Our tool automatically generates this prefix and wraps it in CSS rules (background-image) or HTML (<img src="...">) so all you have to do is copy and paste it into your web project.

Is it suitable for all images?

No. Base64 encoding increases the raw file size by about 30%. This technique is excellent for small files (icons, simple logos under 5 KB). On the other hand, encoding a very large vector illustration or a JPG/PNG photo as Base64 is poor SEO practice because it would significantly bloat your CSS or HTML file.

More dev & UI tools:

How it works

How to use the SVG to Base64 converter

Convert an SVG into a Base64 data URI to embed directly in your CSS or HTML.

  1. Paste your content

    Paste the SVG code or import the file.

  2. Convert

    The data URI is generated.

  3. Copy the result

    Copy or download the result in one click.

FreeNo subscription, no hidden limits.
No sign-upOpen the page and use the tool. That’s it.
InstantResults in seconds, on mobile too.
PrivateEverything runs in your browser.

About the SVG to Base64 converter

Embedding an icon as a data URI saves an extra HTTP request, which is handy for small icons used as CSS backgrounds.

svg to base64 svg data uri convert svg to base64 svg base64 css background svg to data url embed svg in css base64 svg encoder
FAQ

Frequently asked questions about the SVG to Base64 converter

Base64 or URL-encoded?

For SVG, URL encoding is often lighter, while Base64 remains the most compatible.

How do I use it in CSS?

background-image: url("data:image/svg+xml;base64,…").

Is it suitable for large images?

No. Keep it for small icons.

Is the file sent anywhere?

No. The conversion is local.

Esc
↑ ↓ navigateEnter open