DEVELOPER TOOLKIT · SVG & CSS
SVG Data URI Converter & Embed Studio
Encode SVG to strict percent or Base64 data URIs, preview CSS and HTML embeds, or decode an existing asset. Your artwork stays in this browser.
SVG source
Paste or drop an SVG file. Maximum 750,000 UTF-8 bytes. Original XML is retained byte-for-byte as text.
Image-context preview
Not renderedPreview will appear here
Source safety & compatibility
Encoding does not sanitize SVG. A data URI may be blocked by your site's CSP; standalone SVG can behave differently from an image.
Destination-ready output
No output yetThe preview and downloads refer to the current, validated source. Downloading a snippet does not sanitize the original SVG or publish it to your site.
Decode existing raw SVG data URI or CSS/HTML wrapper
Batch SVG asset maker
Choose up to 20 small local SVGs. Export reusable CSS variables and a JSON manifest. Invalid files stay separate.
No assets imported.
How to use SVG to CSS Data URI Converter
- Paste valid SVG XML, including an optional XML declaration.
- Choose percent encoding or Base64 and raw URI, CSS declaration or HTML image output.
- Encode and copy or download the snippet. Open the Decode panel to recover SVG from a raw URI, CSS url(), or HTML img wrapper without replacing your source.
When to use this tool
Embed an SVG icon in a CSS background or move it through a text-only field. Compare percent encoding with Base64 and verify that the destination accepts data URIs.
Encoding preserves markup; it does not sanitize it
Percent encoding represents reserved characters explicitly, including spaces and quotes. Base64 first encodes Unicode as UTF-8 bytes. The preview loads the URI as an image. Decoding accepts the supported image/svg+xml URI forms and validates that the recovered XML has an SVG root.
Worked example
SVG: <svg xmlns="http://www.w3.org/2000/svg"/>
URI starts: data:image/svg+xml,%3Csvg
CSS: background-image: url("data:image/svg+xml,..."); Choose the wrapper expected by an icon’s destination
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"><rect width="16" height="16" fill="#2463eb"/></svg>
- Paste this authored icon or a reviewed SVG and select percent encoding or Base64.
- Choose Data URI for a URI field, CSS background-image for a declaration, or HTML img tag for markup. The wrappers are not interchangeable.
- Inspect the preview and encoded text. For decoding, paste the URI or a supported wrapper into the Decode panel. The raw
data:image/svg+xml,...value is extracted locally; multiple candidates require an explicit selection. - Keep the original SVG separately from the encoded-text download. Encoding changes representation, not image dimensions.
Original SVG, no encoded artifact or embedding test. Reversible encoding does not remove active markup or external references. Use SVG Optimizer for source optimization; large assets may be better retained as separate files.
Limits and output checks
Decoding supports strict SVG data URIs and selected CSS/HTML wrappers. Preview and embed contexts may be limited by CSP or external references. Large SVGs may be better hosted as separately cacheable files.
Reference: Data URL syntax.
Frequently asked questions
Can I use an XML declaration?
Yes. The XML parser validates the document and SVG root rather than requiring the source to start literally with <svg.
Does Base64 make an SVG private?
No. Both supported encodings are reversible representations.
Can I decode CSS directly?
Paste a supported raw URI or a CSS url()/HTML img wrapper into Decode. If several URIs are present, select the intended candidate.
Does a data URI work with all email clients and CSPs?
No. Some email clients reject data URLs, and site Content Security Policies can restrict image data sources. Test in the actual target environment or host a normal SVG file.
Can this tool clean scripts or external links?
No. Its safety inspector reports known concerns, and unsafe sources are withheld from preview. Exporting the original source leaves all markup unchanged. Use a dedicated, reviewed sanitizer when appropriate.
Encoding an SVG does not sanitize it
Use the Decode panel to inspect raw data URIs or supported CSS/HTML wrappers. Encoding preserves SVG content and does not remove executable markup for standalone/inline use.
Scope of this workflow
Base64 and URL encodings are reversible. Scripts, links or external references in source markup are not removed by encoding.
SVG Optimizer - Precision & ViewBox Preservation · All developer tools · Privacy policy · Contact PixelOkay