Toolvist

SVG to Base64 Converter

Convert SVG code to a Base64 encoded data URI.

Preview appears here

Free SVG to Base64 Converter

The SVG to Base64 Converter encodes SVG markup into a data URI you can embed in CSS, HTML, or an img tag. Choose between Base64 and URL-encoded output.

The raster equivalent is the Image to Base64 Converter, and the asset itself can be reduced first with the SVG Optimizer. To rasterise it instead of encoding it, the SVG to PNG Converter is the tool.

How to use the SVG to Base64

  1. 1 Paste the SVG markup, or drop an `.svg` file. The source must be valid XML.
  2. 2 Choose whether to output a data URI for CSS, a bare Base64 payload, or an `<img>` tag.
  3. 3 Minify first if you are inlining into CSS — stripping whitespace and metadata often cuts the file by half before encoding even begins.
  4. 4 Copy the result. For CSS, wrap it as `url("data:image/svg+xml;base64,…")`.

When to inline vector art

The case for inlining SVG is strongest when the asset is tiny, used on almost every page, and would otherwise cost a separate HTTP request — a chevron, a check mark, a logo mark. The case against it is that the bytes are copied into every place the asset appears, and no cache can help after the first visit because the value is embedded in the stylesheet itself.

A sprite solves the middle ground. One external file holds every symbol, the cached copy is shared across all pages, and each use site is a single short reference rather than a duplicated payload. For an icon set of any size, that is almost always the right answer.

  • Add `;charset=utf-8` when the markup contains non-ASCII characters.
  • SVGZ is a gzipped SVG and usually beats Base64 outright on wire size.
  • Strip editor metadata first: `<metadata>`, comments and empty groups contribute nothing.

Frequently asked questions

Should I use Base64 or URL-encoding for an inline SVG?

URL-encoding usually wins for SVG. Base64 adds 33% overhead on top of markup that is already text, and it makes the value impossible to read or edit in place. Percent-encoding keeps the markup visible, compresses better under gzip, and only requires escaping a handful of characters such as `#`, `<`, `>` and quotes. Reach for Base64 only when the surrounding context cannot carry the special characters.

Why can I not change the colour of an inlined SVG with CSS?

Because an inline data URI is treated as an embedded document, not as DOM you can style. `currentColor` and your stylesheet rules cannot reach inside it. To inherit the text colour, the SVG needs to be inlined as actual markup in the HTML, or the colours need to be baked into the file.

Does inlining an SVG help page speed?

Only for small, frequently-used icons, and only because it removes a round trip. A sprite of every icon in a set is usually the better trade: one small file, correctly cached, instead of adding the same weight to every stylesheet that uses it.

Related Image & Color Tools

Browse all Image & Color Tools →

You might also need

Tools from other categories that people pair with the SVG to Base64:

Browse the full tool directory →