Paste SVG markup and get a live preview plus base64 and URL-encoded data URIs, with ready-to-paste <img> and CSS background snippets. Runs entirely offline; your markup never leaves the browser and persists here via localStorage.
| Raw SVG | — |
| Base64 data URI | — |
| URL-encoded data URI | — |
| Smaller | — |
An SVG can be embedded directly in an <img src> or a CSS url() as a data URI, saving an HTTP request. There are two encodings. Base64 (data:image/svg+xml;base64,…) is universally safe but inflates the payload by about 33%. URL-encoding (data:image/svg+xml,…) keeps the markup as text with only the reserved characters escaped, so for SVG — which is mostly ASCII — it is almost always smaller and stays human-readable. This tool shows both sizes so you can pick; URL-encoding usually wins for inline SVG.
Base64 is UTF-8 safe here (the markup is UTF-8 encoded before btoa, so non-ASCII characters survive). The URL-encoding follows the widely used minimal scheme: double quotes become single quotes (so the URI itself can sit in double quotes), whitespace between tags is collapsed, and only %#()<>?[\]^`{|} and newlines are percent-escaped — everything else stays readable. If your root <svg> is missing the xmlns="http://www.w3.org/2000/svg" namespace, the tool adds it (toggle above), because without it the browser won't render the data URI as an image.
<img> or CSS url() — the same safety property demonstrated in the SVG base64 embedding sandbox. Inline <svg> in the document is a different story and can run script.data: URI scheme and base64). https://developer.mozilla.org/en-US/docs/Web/URI/Schemes/data