SVG to JSX Converter
Turn any SVG into a React (JSX/TSX), Angular, Vue or Svelte component with a size prop and currentColor. SVGO cleanup built in; nothing is uploaded.
Framework
Preview appears here
How to Convert SVG to a React Component
- Add your SVG. Paste the SVG code, drop an .svg file on the box, or upload one. Icons from Figma, Illustrator, Sketch and icon libraries all work.
- Pick a framework. Choose React (JSX or TSX), Angular, Vue or Svelte, and name the component.
- Set the options. Keep the size prop and currentColor on for icons, so one component works at any size and in any text colour. SVGO cleanup strips editor junk first.
- Copy or download. Copy the component or download it as a ready-to-import file.
What Changes When SVG Becomes JSX
SVG pasted straight into JSX usually fails to compile or logs warnings. These are the rewrites the converter makes for React. Angular, Vue and Svelte keep normal SVG attribute names, so they only get the size, colour and cleanup changes.
| SVG | JSX | Why |
|---|---|---|
| class="icon" | className="icon" | class is a reserved word in JavaScript. |
| stroke-width="2" | strokeWidth="2" | React uses camelCase for hyphenated SVG attributes. data-* and aria-* stay as they are. |
| xlink:href="#a" | href="#a" | xlink:href is deprecated in SVG 2, and plain href works in every current browser. |
| style="fill-opacity:.5" | style={{ fillOpacity: 0.5 }} | React takes styles as an object, not a string. |
| width="24" height="24" | width={size} height={size} | A size prop lets one component render at any size. |
| fill="#1F2937" | fill="currentColor" | The icon then follows the CSS text colour, including hover and dark mode. |
| sketch:type, inkscape:label | (removed) | Editor attributes are not valid JSX and do nothing in the browser. |
Using the Component
import { PaperPlaneIcon } from './PaperPlaneIcon';
<button className="text-blue-600 hover:text-blue-800">
<PaperPlaneIcon size={20} /> Send
</button>Using Angular Material? To move mat-icon from the icon font to SVG files, use the mat-icon SVG Migration Helper. To shrink the SVG itself, run it through the SVG Optimizer.
Need an icon to start from? Browse Material Symbols, Lucide, Heroicons, the free CC0 icon packs or this week's new icons.
Frequently Asked Questions
- Is my SVG uploaded anywhere?
- No. The conversion and the SVGO cleanup both run in your browser, so private logos and unreleased designs never leave your device.
- How is this different from SVGR?
- SVGR is the standard build-time tool for React and does a similar transform. This page is for when you want the component code itself, for one icon, without adding a build step, and it also writes Angular, Vue and Svelte versions, which SVGR does not.
- Why does my converted icon render black?
- With currentColor on, the icon takes the CSS color of its parent. Set color on the parent or pass a className or style. The preview above shows currentColor as black because an image has no parent text colour.
- When should I turn currentColor off?
- For multicolour artwork such as logos and illustrations. The tool counts the colours in your SVG and turns currentColor off by itself when there is more than one.
- Does the React component accept other props?
- Yes. Everything you pass, such as className, onClick or aria-label, is spread onto the svg element. In TSX the props are typed as SVGProps<SVGSVGElement>.
- Which Angular version does the component need?
- It uses the input() signal API, so Angular 17.1 or later. Components are standalone by default from Angular 19, so there is no standalone flag. On older versions, change input() to @Input().
- Why is aria-hidden="true" added?
- Icons next to a text label are decoration, and screen readers should skip them. When your SVG has a <title>, an aria-label or a role, the tool leaves it accessible instead. You can also pass aria-label to the component to override it.
- What happens to <style> blocks in the SVG?
- SVGO moves simple styles onto the elements. What is left is kept as a style element: a template literal in React and Svelte, a normal style tag in Angular, and a component is="style" tag in Vue, which does not allow style tags in templates.
Sources & Standards
Last reviewed .
Related Tools
SVG OptimizerCompress SVG files with SVGO 4 in your browser. Before/after size, gzip size and preview, plus batch optimize up to 200 files to a .zip.SVG to PNG, ICO & FaviconExport an SVG as a sharp PNG, WebP or JPG at any size, a multi-size .ico, or a complete favicon set with Apple touch icon, maskable icons and manifest.mat-icon SVG Migration HelperMove Angular Material mat-icon from the icon font to SVG: rewrites templates to svgIcon, downloads only the Material Symbols you use, and writes the MatIconRegistry code.Lucide Icons ExplorerSearch 1,550+ Lucide vector icons by name or tag. Customize stroke width, size and colors, and copy React, Angular, Vue, Svelte, or clean SVG code.Free Icon Packs: Holidays, AI & DevicesOriginal line icons for Christmas, New Year, Ramadan and Eid, AI and new devices, free under CC0. Lucide-style 24×24 grid; copy SVG, React, Angular or Vue code, or download a whole pack.