๐Ÿ”’ Runs in your browser โ€” nothing is uploadedโœ“ Free, no signup

SVG to JSX โ€” React Component Converter

Paste an SVG to turn it into a React component. Attributes are converted to camelCase, and you can make the icon resizable and colourable with props and currentColor.

Loading...

0 characters

React component

Loading...

When should you use the SVG to JSX?

  • Turning icons exported from Figma or Illustrator into React components
  • Making SVG icons inherit text colour with currentColor
  • Building a small icon set without extra tooling

How to use the SVG to JSX

  1. 1

    Paste SVG

    Paste the full <svg> markup โ€” the XML declaration is removed automatically.

  2. 2

    Name the component

    Use a PascalCase name such as ArrowIcon.

  3. 3

    Make it flexible

    Remove width/height and spread props so you can size it with CSS, and use currentColor to colour it with text colour.

  4. 4

    Copy

    Copy the component or download it as a .jsx file.

Examples

Icon with props

SVG

<svg width="24" height="24" viewBox="0 0 24 24" stroke-width="2">
  <circle cx="12" cy="12" r="10"/>
</svg>

JSX

export default function Icon(props) {
  return (
    <svg viewBox="0 0 24 24" strokeWidth="2" {...props}>
      <circle cx="12" cy="12" r="10" />
    </svg>
  );
}

Common errors and how to fix them

Invalid SVG
The markup must be well-formed XML โ€” every tag closed and attribute values quoted. Export the SVG again from your design tool.
The icon doesn't change colour
Tick 'Use currentColor', then set the CSS color of the parent element.
Related tools:ย HTML to JSX ยท Image to Base64 ยท CSS Gradient Generator

More from Code Formatters & Minifiers

Free tools that run in your browser โ€” no signup, nothing uploaded.

SVG to JSX FAQ

Hyphenated SVG attributes become camelCase โ€” stroke-width โ†’ strokeWidth, fill-rule โ†’ fillRule โ€” class becomes className, and xlink:href becomes xlinkHref. data-* and aria-* attributes are kept as they are.

It replaces fill and stroke colours with currentColor, so the icon takes the CSS text colour of its parent โ€” handy for icons in buttons and links.

Without fixed sizes, the icon scales with CSS or props like width={32}, while viewBox keeps its proportions.

It passes any props you give the component โ€” className, width, onClick, aria-label โ€” straight to the <svg> element.

No โ€” it converts the markup as is. Optimise first with a tool like SVGO if you want smaller files.

No. Everything runs in your browser, so your SVG never leaves your device.