SVG → Base64

SVG to Base64

Turn an SVG into a data URI you can paste straight into HTML or CSS — Base64 and the usually smaller URL-encoded form, side by side.

SVG → Base64

☞ tout se passe dans ton navigateur — rien n’est envoyé

Drop your SVG here

or click to browse — SVG only

one less request

Why inline an SVG as a data URI

A data URI puts the image inside the HTML or CSS itself, so the browser never makes a second request for it. For small icons that is the difference between appearing instantly and appearing a moment late.

The trade-off is caching: an inlined icon is re-downloaded with every page that contains it, and it cannot be cached on its own. Inline the handful of icons that matter for the first paint, and leave the rest as files.

three steps

How to encode an SVG as Base64

01

Drop the SVG

Pick a .svg file — it stays on your device.

02

Pick a form

Copy the Base64 or the URL-encoded data URI.

03

Paste it in

Use the ready-made img tag or CSS background rule.

quick answers

SVG to Base64 FAQ

Base64 or URL-encoded — which should I use?

URL-encoded is usually smaller for SVG, because SVG is text and Base64 adds about 33% to anything it touches. URL-encoded is also readable, so you can spot the shape you meant in a stylesheet. Use Base64 when something in the pipeline mangles the raw characters.

Why is my data URI bigger than the file?

Base64 encodes three bytes as four characters, so a third of the growth is unavoidable. Run the file through the SVG optimizer first — editor metadata and over-precise coordinates often account for more than the encoding does.

Can I use this in a CSS background?

Yes — the CSS block is ready to paste. It uses the URL-encoded form inside double quotes, which is why the encoder swaps the SVG’s own double quotes for single ones.

The icon does not show up in my CSS

Almost always an unencoded `#`. A colour like `#fff` cuts the URL short at that point, and everything after it is treated as a fragment. The output here already escapes it — the problem usually appears when a data URI is hand-edited afterwards.

Is my file uploaded?

No. The encoding is plain string work done in your browser.