SVG to React
SVG to React converts an SVG into a React component with the right attribute names, style objects and optional TypeScript, props, currentColor and memo, and drops editor junk. It runs in your browser, so your SVG is never uploaded.
How to use SVG to React
- Paste your SVG or drop the file.
- Name the component and choose JavaScript or TypeScript.
- Copy the component into your project.
Frequently asked questions
Is my SVG uploaded?
No. The conversion runs in your browser and nothing is sent anywhere.
What changes besides attribute names?
class becomes className, stroke-width becomes strokeWidth, inline style strings become objects, and comments, the XML declaration, editor namespaces and metadata are removed. A note under the result lists what was changed.
How do I make the icon take the text colour?
Turn on Use currentColor. Fills and strokes then use the colour of the surrounding text, so you can change it with CSS.
Does it work with Next.js, Vite and React Native?
The output is standard JSX and TSX, so it works with Next.js and Vite. React Native needs react-native-svg components instead, which this tool does not produce.
Next step
Smaller components start with a smaller SVG. Optimize it first. Open SVG Optimizer.
Related tools
- 109