Tool guide
About this tool.
- A data URI puts a whole file inside a URL, so a small SVG icon can live in CSS or HTML without a separate request. The URL-encoded form percent-encodes only the characters that break a URL, such as #, % and <, and is usually smaller than Base64.
- The CSS output wraps the data URI in an .icon rule with background-image, background-repeat: no-repeat and background-size: contain.
- The JSX output turns the SVG into a React component. class becomes className, namespaced and hyphenated attributes become camelCase (xlinkHref, strokeWidth), data-* and aria-* stay as they are, and a style attribute becomes a style object. The root receives {...props} last, so callers can override any attribute.
- Inline icons in CSS without an extra HTTP request.
- Background images for buttons, list markers and form controls.
- Turning a designer export into a React icon component.
- Checking that an SVG from an unknown source has no script before you inline it.
Paste SVG markup and pick an Output: Data URI, CSS or JSX.
For a data URI or CSS, choose URL-encoded or Base64. For JSX, set the Component name and turn on TypeScript if you need types.
Optimize first is on by default and reports the saved bytes.
The preview shows the SVG that was converted. SVG with script, event handler attributes or javascript: URLs is rejected.
- <svg …><path d="M5 12l5 5L20 7"/></svg> → data:image/svg+xml,%3Csvg …
- Output CSS → .icon { background-image: url("data:image/svg+xml,…"); … }
- Encoding Base64 → data:image/svg+xml;base64,PHN2Zy…
- class="a" stroke-width="2" → className="a" strokeWidth="2"
- style="stroke-width: 2; --x: 1" → style={{ strokeWidth: '2', '--x': '1' }}
- <svg onload="…"> → rejected, the attribute onload can run script
- Input is at most 500,000 characters; the root element must be <svg>.
- DOCTYPE declarations are rejected, so external entities are never loaded.
- The component name must be PascalCase, such as Icon or ArrowLeft.
- Attribute values with a double quote print as {'…'} expressions.
- Braces and angle brackets in text print as {'{'} style expressions.
- Optimize drops Inkscape and Sodipodi editor elements; other elements JSX cannot express are rejected, never dropped.