svgby garagemade

Convert an SVG to a React component

svgby garagemade
0,0browser-local
Drop an SVG to start
or pick a sample on the home page

Pasting a raw SVG into JSX rarely compiles — React wants camelCase attributes, className instead of class, and a style object rather than a string. This turns the SVG in the editor above into a paste-ready React component, JSX or TSX, so it drops into a project without hand-editing. Everything runs in your browser; the SVG never leaves your machine.

How to convert an SVG to React

  • Load your SVG above, or edit the sample. It stays in your browser.
  • Open the Code tab — it opens on React — and set the component name.
  • Toggle TSX for a typed component, or JSX for a plain one.
  • Copy the component, or download it as a .tsx or .jsx file.

What the React component gives you

  • A function component whose root <svg> spreads {...props}, so you pass className, width, style, or aria-label from where you use it.
  • Correct React attribute names — class className, stroke-width strokeWidth — and inline styles converted to an object.
  • Optional React.memo to skip re-renders when props are unchanged, and forwardRef to expose the underlying svg node.
  • Valid TSX types (React.SVGProps<SVGSVGElement>) when you want them, or clean JSX when you don't.

currentColor makes it themeable

With “replace fill with currentColor” on, the icon follows the surrounding text color. One component then recolors through CSS — no duplicate files per color, no re-export when the palette changes. That's the difference between a react component you configure at the call site and a static asset you copy: the same jsx works in a button, a heading, and a dark theme, and the tsx version keeps it type-checked while it does.

Frequently asked questions

Does it output TypeScript?
Yes. Turn on TSX and the component is typed as React.SVGProps<SVGSVGElement>; choose JSX for a plain .jsx file with no types.
Can I theme the icon with CSS?
Turn on “replace fill with currentColor” and the SVG inherits the surrounding text color, so one component recolors through the CSS color property.
Does it rename attributes for React?
Yes. class becomes className, kebab-case attributes such as stroke-width become strokeWidth, and an inline style string becomes a style object.
What do the memo and forwardRef options do?
Both are optional. forwardRef passes a ref through to the root svg element; memo wraps the component so it re-renders only when its props change.
Can I pass my own props to the SVG?
Yes. The root svg spreads your props, so className, width, style, onClick, and aria-label flow straight through from the call site.
Do you upload my SVG?
No. The component is generated in your browser from the SVG you loaded. Nothing about the file is sent to a server or stored.
Is it free?
Yes. No signup, no watermark.