SVG to React Component

Convert SVG into a React component with props forwarded

Runs in your browserUtility02Converters

What is SVG to React Component?

This SVG to React converter rewrites icon markup as a function component: hyphenated attributes become camelCase, xmlns is removed, and props are spread onto the root element. You can emit either a TypeScript or a JavaScript version, and the conversion runs entirely in your browser.

How to use SVG to React Component

  1. 1Paste the SVG source.
  2. 2Enter a component name. It is converted to PascalCase automatically.
  3. 3Choose whether to include TypeScript type annotations.
  4. 4Copy the component into your project icon directory.

Frequently asked questions

Why forward props onto the root svg element?+

It is what lets callers control size, color, and accessibility attributes, as in <PlusIcon width={20} aria-hidden />. Set stroke to currentColor and let the surrounding text color drive it, and one component adapts to every theme you have.

What is the best way to convert icons in bulk?+

Once a project has a large icon set, use the SVGR build plugin so that .svg imports are compiled into components at build time. That removes the manual step and stops the icon files and the components from drifting apart. This tool is best for adding the occasional one-off icon.

Related tools

All tools