How to use SVG to Data URI Converter
- Paste one supported SVG document, or choose a UTF-8 SVG file to replace the text.
- Choose Percent-encoded or Base64. Leave Trim outer whitespace off when the outer whitespace should remain part of the encoded value.
- Choose whether to include a CSS background-image declaration. Copy the URI or declaration from the result; the converter does not render the SVG.
Example: SVG to Data URI Converter
Encode a simple triangle SVG and include its CSS background-image declaration.
Options
- Input and markup subset
- Pasted markup accepts up to 128 KiB; a selected UTF-8 file has a tighter 100,000-byte cap. The root must be svg with the standard namespace. Supported basic shapes, groups and text use an attribute allowlist; this is not an arbitrary SVG parser.
- Encoding
- Percent encoding keeps unreserved text readable and escapes reserved URI characters. Base64 represents the UTF-8 bytes with its own alphabet. Either can be longer depending on the markup, so compare the reported URI character counts.
- Outer whitespace
- Trim is off by default, preserving accepted markup including its surrounding whitespace. Turning it on removes whitespace only at the outside; it does not minify paths or simplify geometry.
- CSS declaration
- Add a CSS background-image rule includes a quoted url() declaration after the URI. An SVG used as a CSS image has its own image context; surrounding text color should not be assumed to carry into currentColor.
Supported inputs and limits
- Pasted SVG up to 128 KiB, 5,000 elements, 32 levels and 24 attributes per element.
- A chosen UTF-8 file replaces pasted text and is limited to 100,000 bytes.
- Scripts, styles, events, images, frames, hrefs, url() references, XML entities, DTDs, processing instructions and unsupported constructs are refused.
- No SVG is rendered inline, uploaded, optimized or downloaded as a new file.
- Encoding changes representation, not geometry or file complexity.
Where your input is processed
This tool does not upload your inputs. See the limits for anything saved on your device.
Embedding does not remove SVG complexity
A data URI packages the markup into a string. It does not simplify paths, make external content local or guarantee image support. The supported subset and input cap keep this conversion bounded.
Questions about SVG to Data URI Converter
Why is the hash in a color encoded?
An unescaped hash can start a URI fragment. Percent encoding keeps it inside the SVG data.
Does Base64 reduce the size?
Usually it increases the encoded length. Percent encoding may be shorter for simple SVG, so compare the actual outputs.
Will currentColor use the surrounding text color?
An SVG used as a CSS image is a separate image context. Do not assume the surrounding element’s text color carries into it.