SVG to Base64 & Data URI Encoder

Paste SVG code, get a base64 or URL-encoded data URI plus a ready-to-paste CSS snippet, instantly, in your browser.

SVG input
Load example
Encoded output
Base64 String
Data URI
CSS background-image

Runs Entirely in Your Browser

This tool doesn't touch a server, your SVG is encoded entirely inside your browser using client-side JavaScript, then discarded the moment you leave the page. Nothing is stored, logged, or sent anywhere, which matters if the icon or graphic you're converting is proprietary or hasn't shipped yet. You can technically run it offline once the page has loaded.

One SVG, Three Ready-To-Use Formats

SVG markup can be encoded two ways for embedding: standard Base64, which works everywhere but adds roughly 33% to the file size, and URL-encoding, which stays smaller for simple SVGs but can break on more complex markup with special characters. This tool supports both, and packages the result into three ready-to-use formats — a raw Base64 string, a complete Data URI (data:image/svg+xml;base64,...), and a CSS background-image snippet you can paste directly into a stylesheet.

Base64

The raw encoded text, useful when embedding into your own custom format.

Data URI

A complete, ready-to-render string for an <img src> or CSS url().

CSS background-image

A full snippet you can paste directly into a stylesheet.

Common Use Cases

Inline icons in CSS

Embed a small icon directly as a background-image without adding an extra HTTP request for a separate file.

Icons in HTML emails

Inline an SVG as a Data URI inside an <img> tag, since many email clients block externally linked images by default.

Store icons in JSON or config files

Keep a logo or icon inline as a string inside a design token file, API response, or app configuration.

One-off icons that don't need caching

Skip a separate file request for an icon used in just one place, where browser caching wouldn't offer much benefit anyway.

Preview before committing to production

Check how an SVG actually renders as a Data URI before wiring it into your codebase or design system.

Share a self-contained snippet

Send a single copy-pasteable string that includes the full icon, without needing to attach or link a separate file.

Frequently Asked Questions

No — the conversion happens entirely in your browser using JavaScript. Your SVG markup is never sent to, stored on, or logged by any server, which makes this safe to use for unpublished or proprietary graphics.

Base64 encodes the SVG as a block of alphanumeric characters and works reliably in every browser and context, but increases file size by roughly 33%. URL-encoding replaces special characters with percent-escaped codes and can produce a smaller result for simple SVGs, though it's more prone to breaking on complex markup with unusual characters. If you're unsure, Base64 is the safer default.

A Data URI is the full, self-contained format — 'data:image/svg+xml;base64,...' — that a browser can render directly without needing a separate file. Use a Data URI when you need something that works immediately in an 'src' attribute or a CSS 'url()'; use the raw Base64 string only if you're embedding it into your own custom format or need to construct the URI manually.

Base64-encoded SVGs are commonly used in production for small, frequently-reused icons where saving an HTTP request matters more than the size increase from encoding. For larger or one-off SVGs, linking to a regular '.svg' file is usually more efficient, since the browser can cache a separate file across page loads, while an inlined Data URI gets re-downloaded with every page.

No — Base64 encoding just represents the same SVG markup as text; it doesn't alter, compress, or rasterize the file, so vector quality, gradients, and most static styling are preserved exactly. SVGs with embedded JavaScript or certain external references may not behave identically once inlined, so it's worth testing interactive or animated SVGs after conversion.

Since conversion happens in your browser rather than on a server, there's no hard server-side limit, but very large SVG files may slow down your browser's tab during processing. For typical icons and simple illustrations, size isn't a practical concern.

This tool is built for SVG-to-Base64 conversion specifically. If you need to reverse a Base64 or Data URI string back into raw SVG markup, that's a separate decoding step — check whether Pathwork or SVGIconify offers a dedicated Base64-to-SVG tool for that direction.