SVG to JSX
Convert SVG to a React component
Paste an SVG and get a ready-to-use component: attributes in camelCase, styles as objects, editor junk gone, and props passed through so you can size and colour it from outside.
Runs in this tab. Nothing is uploaded.
Options
Component
Preview
What the converter changes
- Attributes become React props:
stroke-width→strokeWidth,class→className,xlink:href→xlinkHref.data-*andaria-*stay as they are. - Inline styles turn into objects, such as
style={{ strokeLinecap: "round" }}. Custom properties like--sizeare kept. - Text that contains braces or other characters JSX treats specially is wrapped in a string, and
<style>blocks become template literals. - Event handlers such as
onclick="…"and editor namespaces are dropped, because they can’t be expressed in JSX.
Options
Spread props places {...props} last, so <Icon width={32} className="logo" /> overrides the defaults. 1em sizing makes an icon scale with the surrounding text, and currentColor makes it take the text colour. With TypeScript the props are typed as SVGProps<SVGSVGElement>. The output works with React 17 and later; no import of React is needed.
Questions
Does it work with Preact, Solid or Vue JSX?
The output uses React’s naming (className, camelCase attributes). Preact accepts it as is. Solid and Vue prefer the original attribute names, so adjust class and hyphenated attributes there.
Why are IDs kept?
Gradients, masks and clip paths are referenced by ID. If you render the same icon several times on one page, give each instance unique IDs, or prefix them with SVG Repair first.
Is my SVG sent anywhere?
No. The conversion runs entirely in your browser; nothing is uploaded.
More SVG tools
- SVG RepairDiagnose and fix broken XML, missing xmlns or viewBox, editor junk, bad IDs and scripts.
- SVG OptimizerSVGO with plugin toggles, precision and multipass. Batch files and download a ZIP.
- SVG ViewerZoom and pan on a checkerboard or colour, see dimensions, file size and the element tree.
- SVG to PNGExport PNG, JPG or WebP at 1× to 8× or an exact width, with any background.
- SVG to JSXTurn an SVG into a React component with camelCase props, style objects and TypeScript.
- SVG to Data URIMinimal URL-encoding or base64, ready-made CSS background-image snippets, size comparison.
- SVG SanitizerRemove scripts, event handlers, javascript: links, foreignObject and external references.
- SVG Path EditorInspect path commands, drag points and handles, convert absolute ↔ relative, round and minify.
- SVG Sprite GeneratorCombine icons into one <symbol> sprite with IDs from file names and a usage snippet.