Convert an SVG into JSX with attributes renamed to their React spelling, as a bare fragment or a complete typed component ready to paste in.
Waiting for an SVG
Sanitised first, then converted. Hyphenated attributes become camelCase and the element names that need their capitals back get them.
The component appears here
Ready to paste into a React project.
SVG to JSX Converter runs entirely on your device — nothing is uploaded.
You’re on the Free plan. Compare plans
Pasting an SVG into JSX does not work, and the reason is that JSX attribute names are JavaScript property names. `stroke-width` is not a valid identifier, so React expects `strokeWidth`; `xlink:href` becomes `xlinkHref`; `clip-path` becomes `clipPath`. Every hyphenated SVG attribute needs renaming, and there are enough of them that doing it by hand is where the typos come from.
SVG element names are case-sensitive and that is the subtler half of the problem. `clipPath`, `linearGradient`, `feGaussianBlur` and the rest of the filter primitives must keep their exact capitalisation or the browser does not recognise them — and a lowercased `clippath` fails quietly, so the clip simply does not apply and nothing in the console says why. The converter restores the correct spelling for every one of them.
Inline `style` attributes become objects, because JSX has no other option: `style="fill: red"` is a string and React wants `style={{ fill: 'red' }}`, with the property names camel-cased too. That conversion is handled as part of the same pass.
The component output is a typed function component spreading `SVGProps<SVGSVGElement>`, which is what makes the icon usable — you can set a className, a size or an aria-label from the outside without editing the file. The markup is sanitised on the way through, so an SVG from a source you do not control does not arrive in your codebase carrying a script.
Because JSX attribute names are JavaScript property names, and hyphenated names like stroke-width are not valid identifiers. React expects strokeWidth, clipPath, xlinkHref and so on, so every hyphenated attribute in the file needs renaming.
Because SVG element names are case-sensitive and the capitalisation was lost. clipPath, linearGradient and the fe* filter primitives must keep their exact spelling; a lowercased clippath is simply not recognised, and it fails without an error.
It becomes a style object with camel-cased property names, which is the only form JSX accepts. style="fill: red" converts to style={{ fill: 'red' }}.
SVGR is a build-time transform for a whole directory of icons and is the right tool for that. This is for the one-off: an icon from a designer that you want in the codebase now, converted in the page with nothing installed and nothing uploaded.
Yes. The component output spreads SVGProps<SVGSVGElement>, so you can pass className, width, height, an aria-label or anything else from the outside without editing the generated file.