SVG to React JSX / TSX & Vue Component Converter

Convert SVG markup to React JSX or TSX, a raw JSX element, or a Vue template. Rename React attributes and optionally use currentColor or remove root dimensions.

Target:
Component Name:
Input Raw SVG Code:
Generated Component:
</> Embed this tool on your website / blog No code required · Copy and paste
HTML Embed Code (iframe):
<iframe src="https://lucentool.com/svg-to-jsx" width="100%" height="650" style="border:1px solid #e5e0d8;border-radius:12px;max-width:850px;width:100%;" frameborder="0"></iframe>
<div style="font-size:12px;color:#78716c;margin-top:6px;font-family:sans-serif;">Powered by <a href="https://lucentool.com/svg-to-jsx" target="_blank" style="color:#c85a32;text-decoration:none;">Lucentool - SVG to JSX & React Component Converter</a></div>

Convert SVG attributes for your framework

Select React JSX, React TSX, a raw JSX element or a Vue template. React output changes common SVG attributes such as class and stroke-width; Vue output keeps the template attribute names.

Example: an SVG element becomes JSX

Select Raw JSX Element and turn off currentColor and dimension removal. This input:

<svg class="icon" stroke-width="2" viewBox="0 0 24 24"></svg>

becomes:

<svg {...props} className="icon" strokeWidth="2" viewBox="0 0 24 24"></svg>

Review the generated component

The raw JSX output expects props to exist in its component scope. This tool rewrites common markup patterns; it does not compile components, sanitize untrusted SVG, or guarantee support for every editor-specific attribute. Check gradient colors before enabling currentColor, and render the result in your project.

Edge cases and hard limits

convertSvgToJsx() parses the markup and rewrites it for JSX: attribute names move to camelCase (stroke-width to strokeWidth, class to className), hyphenated and namespaced attributes are mapped through a lookup table (xlink:href to xlinkHref, xml:space to xmlSpace), inline style strings optionally become objects, and self-closing tags are normalised. The output can target a React component or plain JSX depending on the selector.

Formats, sizes and other limits

Attribute mapping covers the common SVG surface, not every namespaced attribute; unusual ones pass through unchanged and will warn in React. Style conversion handles simple declarations and fails on values that contain semicolons inside quotes. Embedded <style> blocks are not scoped, so two converted icons can collide in one component tree. Scripts inside the SVG are removed, which is safer but changes behaviour if the original relied on them.

Privacy: processed in your browser

The SVG is parsed and rewritten locally. The markup is never uploaded, which matters for client work you cannot share.

Frequently asked questions

Why does React complain about an attribute?

Because the mapping table does not know that attribute. Add the camelCase form manually — React warns on unknown DOM attributes.

Are <style> blocks scoped?

No. An embedded stylesheet applies globally once rendered, so two converted icons with the same class names will conflict.

Does it keep scripts?

No. Scripts inside the SVG are stripped, which is the safe default for icons pasted from unknown sources.