Choose or paste SVG
Drop an SVG file, paste XML markup or paste an SVG data URI to decode it. Try the sample to explore the output formats.
Encode SVG artwork for HTML images, CSS backgrounds and masks, or decode a data URI back to SVG. Compare percent encoding with Base64, preview the result and copy the snippet you need.
Paste or drop SVG · Unicode support · Copy and download · No uploads
Create a data URI for HTML, CSS backgrounds and masks. Your SVG stays on this device.
Choose SVGNo fixed file size limit. One SVG at a time.
Existing percent-encoded and UTF-8 Base64 SVG data URIs are decoded automatically.
Drop an SVG file, paste XML markup or paste an SVG data URI to decode it. Try the sample to explore the output formats.
Let automatic mode choose the smallest URI, or select compact percent encoding, full percent encoding or UTF-8 Base64.
Copy the raw URI or ready-to-use HTML, CSS background, CSS mask, JavaScript or React output. Add alt text for meaningful images.
Inspect the actual encoded image on light, dark or checkerboard backgrounds. Copy the output or download a snippet file.
A data URI stores the SVG document inside a URL string. Instead of pointing to /icons/check.svg, an image can use a source beginning with data:image/svg+xml,. The browser reads the image from that payload. You may also see the term data URL, which describes the same workflow.
The string contains a media type, an optional encoding indicator, a comma and the encoded document. Percent encoding escapes XML characters for the URL. Base64 represents the UTF-8 bytes as ASCII text and adds ;base64 before the comma. Neither approach changes vectors into pixels.
Keep the generated URI on one line and preserve its prefix. A missing comma, unescaped hash or a second encoding pass can produce a valid-looking string that the browser cannot interpret. See the MDN data URL reference for the syntax.
Escapes XML brackets, quotes, hashes, percent signs and Unicode while retaining selected safe punctuation. It keeps the document recognizable and can avoid some Base64 overhead.
Escapes more punctuation. Useful when a workflow expects a fully escaped payload. This tool also escapes single quotes so either quote style can safely wrap the URL.
Uses an ASCII payload generated from the full UTF-8 document. It handles non-Latin text and emoji correctly. The output may be smaller than heavily escaped XML, so compare the actual sizes.
Automatic mode compares all three generated strings and chooses the shortest. The size cards show raw UTF-8 bytes, including the URI prefix. Your site's gzip or Brotli compression may change the relative transfer sizes, so these cards are not a page-speed benchmark.
Whitespace is preserved during encoding because spaces can affect SVG text and xml:space. Optional markup cleanup removes comments, metadata and XML declarations without rounding coordinates or rewriting paths. Use the SVG Optimizer for more extensive controls.
Use the URI in src. Meaningful images need descriptive alt text; decorative images should use alt="". The converter escapes the alt text in its HTML snippet.
<img src="data:image/svg+xml,%3Csvg%20xmlns=%22http://www.w3.org/2000/svg%22%20viewBox=%220%200%2024%2024%22%3E%3Ccircle%20cx=%2212%22%20cy=%2212%22%20r=%2210%22%20fill=%22%232563eb%22/%3E%3C/svg%3E" alt="Blue circle">Wrap the URI in a quoted url() value. Set the element's dimensions separately. Background images are appropriate for decoration; they do not supply alt text.
.decoration {
background-image: url("data:image/svg+xml,%3Csvg%20xmlns=%22http://www.w3.org/2000/svg%22%20viewBox=%220%200%2024%2024%22%3E%3Ccircle%20cx=%2212%22%20cy=%2212%22%20r=%2210%22%20fill=%22%232563eb%22/%3E%3C/svg%3E");
background-size: contain;
background-repeat: no-repeat;
}The mask snippet uses the SVG's transparency as a shape and colors the element with currentColor. This is useful for toolbar and navigation icons that should match the surrounding text. Multicolor artwork should usually stay an image or inline SVG.
JavaScript output includes a quoted constant. React output uses JSX expressions for the source and alt text. Both are escaped as strings, so quotes in your SVG or image description do not end the surrounding code.
Small icons, repeating patterns, CSS decorations and standalone HTML templates are useful candidates. Embedding can keep an asset together with its consuming stylesheet or document and avoid a separate request for that asset.
Large illustrations or an image reused across many pages may work better as a separate SVG file. An embedded image adds bytes wherever the containing HTML or CSS is duplicated; a separate resource can be cached and updated independently.
For browser tabs and application icons, use SVG to Favicon or the App Icon Generator to prepare the required files and manifests.
xmlns="http://www.w3.org/2000/svg". This tool adds it when missing.data: in its permitted image sources. Do not weaken unrelated policy directives.Browser image restrictions and content policy determine what renders. Read SVG as an image and the CSP img-src reference for details.
Paste the complete string beginning with data:image/svg+xml into the same input. The converter recognizes percent encoding and UTF-8 Base64, validates the recovered XML and shows a preview. Expand Decoded / prepared SVG markup to inspect the contents or download an SVG file. Paste only the URI, not its surrounding HTML tag or CSS declaration.
Decoding reverses the URL representation, not earlier optimization. Removed comments and rounded coordinates cannot be recovered. This converter may add a missing namespace, and optional cleanup changes the prepared document. Keep the original when exact formatting matters. For other image types, use Base64 to Image.
There is no fixed file size cap. Decoding, encoding and optional cleanup run in a background worker that you can cancel. XML validation and image rendering still use browser resources, so complex SVGs can take longer or exceed device memory. A processing timeout offers a retry instead of leaving the tool waiting indefinitely. Try disabling cleanup or use SVG Optimizer to simplify an unusually complex file.
Encoding and decoding do not remove scripts or make untrusted markup safe. The preview loads the result as an image, not as inline page markup. Review flagged event handlers, scripts and external resources before opening a downloaded SVG as a document or adding it directly to a website. DTD and entity declarations are rejected; export a standalone SVG without them.
Yes. Paste an SVG data URI into the input. Percent-encoded and UTF-8 Base64 payloads are decoded locally. Open Decoded / prepared SVG markup to inspect or download the SVG. Optional cleanup and namespace repair can change the prepared markup, so keep your original if exact source formatting matters.
An SVG data URI, also called a data URL, contains an SVG document inside a string beginning with data:image/svg+xml. Put that string in an image src attribute or a CSS url() value to embed the image without a separate SVG request.
Compare the actual output sizes. Percent encoding can be compact for ordinary SVG markup. Base64 can be smaller when the text contains many characters that need escaping. Automatic mode chooses the shortest of the generated outputs; this is a raw byte comparison, not a gzip or Brotli measurement.
Encoding changes how the XML is represented in a URL; it does not rasterize the artwork. The optional markup cleanup removes comments, metadata and XML declarations while keeping paths, IDs, the viewBox and text spacing. A missing SVG namespace is added automatically.
A literal hash can be interpreted as a URL fragment. Encoding it as %23 keeps it inside the SVG payload, so fill colors and internal gradient, filter and mask references survive conversion.
Yes. Base64 is generated from UTF-8 bytes, and percent encoding also handles Unicode. The intended glyphs still depend on fonts available when the SVG is displayed.
An SVG used as an image does not inherit the surrounding element's color or CSS variables. Use explicit colors for multicolor artwork. For a monochrome icon that follows text color, use the CSS mask snippet, whose background-color is currentColor.
Check the SVG markup, namespace, viewBox and quoted URL. Make sure external image and font dependencies are available in the intended image context, and check whether the site's Content Security Policy permits data: in image sources.
Your source stays in this browser session. Validation, encoding, preview and optional cleanup run locally. There is no fixed file size cap in the tool; device memory and SVG complexity set practical limits. Small icons are usually a better fit for embedding than large illustrations.
No. Encoding is not sanitization. The preview loads the SVG as an image, where browser image restrictions apply. The tool flags scripts, event handlers and external references so you can review the source before reusing it as a standalone document or inline markup.