Tools / SVG to JSX Converter

SVG to JSX Converter.

Turn an SVG file into a React component with camelCase attributes, props spreading and editor junk removed.

Runs in your browser

Leave empty for the bare <svg> JSX.

Lets CSS size the icon; the viewBox keeps the aspect ratio.

Ctrl/⌘ + Enter to run · Ctrl/⌘ + Shift + C to copy the result

Result
JSX
Stats

About SVG to JSX Converter

The SVG to JSX Converter turns an SVG file exported from Figma, Sketch, Illustrator or Inkscape into JSX that React accepts, optionally wrapped as a ready-to-import icon component. The SVG is parsed as XML, so a broken file is reported with its line and column instead of producing silently wrong markup. Every hyphenated presentation attribute is renamed to the camelCase form React uses - stroke-width becomes strokeWidth, fill-rule becomes fillRule, stop-color becomes stopColor - and namespaced attributes follow the same rule, so xlink:href becomes xlinkHref and xml:space becomes xmlSpace. class becomes className and style strings become style objects. With clean-up on, the XML declaration, comments, <metadata> and editor-specific elements and attributes such as sodipodi:namedview or inkscape:label are removed, which usually shrinks the output. Turning on "remove width and height" lets the icon scale with CSS while the viewBox keeps the proportions, and props spreading puts {...props} on the root <svg> so callers can pass className, aria-label or onClick. The TypeScript option types the props as React.SVGProps<SVGSVGElement>. For example <path stroke-width="2"/> becomes <path strokeWidth="2" />. Check icons that rely on ids: two inline copies of the same SVG share id values such as gradient ids. All of this runs in your browser.

How to Use

  1. Paste the SVG markup.
  2. Set the component name and the props, TypeScript, size and clean-up options.
  3. Copy the component into your project.

Frequently Asked Questions

Why convert SVG to JSX instead of using an <img> tag?

Inline JSX lets you style the icon with currentColor and CSS, animate parts of it and pass props such as className or aria-label, with no extra request.

What is removed by the clean-up option?

Comments, the XML declaration, <metadata>, and elements or attributes in editor namespaces (sodipodi, inkscape, sketch, figma, Illustrator's i: and x:). Drawing elements are never removed.

Will two copies of the same icon conflict?

They can if the SVG uses id attributes, for example for gradients or clip paths, because ids must be unique in the page. Rename the ids or use an optimizer that prefixes them.

Is the SVG uploaded?

No. The conversion runs in your browser.

Related Tools