🌐 EN

⚛️ SVG to React JSX Converter

Paste SVG markup to convert it into JSX you can drop straight into a React component. It camelCases attributes (class→className), turns the style string into an object, and strips comments and DOCTYPE.

GUIDE

Learn more

01

1. Why convert SVG to JSX

React (JSX) syntax differs slightly from HTML/SVG. Hyphenated attributes (stroke-width) must be camelCased (strokeWidth), class becomes className, and style must be a JavaScript object rather than a string. This tool converts those differences automatically, so an SVG icon exported by a designer can be pasted directly into a React component.

02

2. Conversion rules

It maps class→className and for→htmlFor, camelCases hyphenated attributes like stroke-width and fill-opacity, converts namespaced attributes such as xlink:href to xlinkHref, and leaves data-/aria- attributes as-is. style="fill:red;stroke-linecap:round" becomes the object style={{ fill: 'red', strokeLinecap: 'round' }}, while comments, DOCTYPE and the XML declaration are removed.

03

3. Safe DOMParser-based conversion

Rather than regex, this tool actually parses the SVG with the browser's DOMParser and re-serializes it, so nested structure and attributes are handled correctly. Everything runs in your browser and the code is never sent to a server. After pasting the result into a component, refine it as needed — e.g. lift width/height to props or switch fill to "currentColor".

Frequently asked questions

Can I use the output directly in React?
Yes. Paste the JSX inside your component's return. Optionally lift size and color to props to make it more reusable.
Is the style string converted too?
Yes. A string like style="a:b;c:d" becomes the object style={{ a: 'b', c: 'd' }} with CSS property names camelCased.
Is my SVG sent to a server?
No. Conversion runs entirely in your browser and the code is never sent to a server.
Does it use a library like svgr?
No. It is implemented directly with the browser's built-in DOMParser, with no external library.