SVG to JSX

Paste SVG markup and get React-ready JSX with camelCase attributes, className, style objects, and TypeScript props.

drop .svg file
// Error converting SVG

Conversions applied

stroke-width → strokeWidthfill-rule → fillRuleclass → classNamestyle string → objectxlink:href → hrefRemoves editor namespaces{...props} spread

Why raw SVG does not work directly in React: and how to fix it

If you have ever pasted an SVG icon directly into a React component and hit a wall of red errors, you know the problem. JSX is JavaScript syntax, not HTML: and SVG was designed long before React existed. The mismatch means every hyphenated attribute name (stroke-width, fill-rule, clip-path) is a syntax error in JSX, and reserved words like class conflict with JavaScript keywords.

The fix is a mechanical transformation: convert kebab-case to camelCase, rename class to className, convert style strings to objects. This tool does all of that automatically, producing a clean, reusable React component that accepts props and can be customized with className, onClick, or any SVG attribute. Adding TypeScript support gives you full IntelliSense across your entire codebase.

How to convert SVG to JSX: step by step

  1. 1
    Paste your SVG markup
    Copy the SVG code from your editor or icon library and paste it into the input area on the left. You can also drag and drop an .svg file.
  2. 2
    Set your component name
    Type a PascalCase name for your React component: for example MyIcon or LogoSvg. The output will export that name.
  3. 3
    Toggle TypeScript props
    Enable TypeScript props to get an interface that extends React.SVGProps<SVGSVGElement> and a React.FC type annotation, ready for strict TypeScript projects.
  4. 4
    Copy the JSX output
    The right panel shows the converted component in real time. Click Copy to grab it and paste it directly into your React or Next.js project.
  5. 5
    Drop it into your project
    Paste the component file into your src/components/icons/ folder. The {…props} spread means callers can pass className, onClick, size, and any SVG attribute through.

Related Tools

Frequently Asked Questions

Why do SVG attributes need to be converted for JSX?
React's JSX is JavaScript, and JavaScript property names cannot contain hyphens. Attributes like stroke-width and fill-rule must become camelCase: strokeWidth and fillRule. Similarly, class conflicts with the JavaScript keyword class, so it becomes className in JSX.
What conversions does the tool apply?
The tool converts all SVG-specific kebab-case attributes to camelCase (strokeWidth, fillRule, clipPath, etc.), converts class to className, converts inline style strings to JavaScript objects, maps xlink:href to href, and removes Inkscape/Sodipodi editor namespaces.
Why does the component spread {...props} onto the SVG element?
Spreading props lets the parent component pass any SVG attribute: className, onClick, aria-label, width, height: without the icon component needing to explicitly declare each one. This is the standard React icon component pattern.
Can I use this with TypeScript?
Yes. Enable the TypeScript props toggle to get an interface extending React.SVGProps<SVGSVGElement> and a React.FC annotation. This gives you full type safety and autocomplete for every SVG attribute.
Does the converter handle style attributes?
Yes. A style string like style='fill: red; stroke-width: 2px' becomes style={{ fill: 'red', strokeWidth: '2px' }}: a JavaScript object that React expects.
What happens to Inkscape and editor-specific attributes?
The tool silently strips attributes and namespace declarations added by Inkscape (inkscape:label), Sodipodi, and similar editors because they are not valid JSX and serve no browser purpose.
Can I convert multiple SVG icons at once?
Currently the tool converts one SVG at a time. For batch conversion of many icons, consider running SVGR in your project's build pipeline.
Does the tool handle defs, gradients, and clipPaths?
Yes. The converter preserves defs elements and all their children so gradients, patterns, filters, and clipPath definitions are kept intact in the output component.

AlteredIdea vs alternatives

vs other online tools: Everything runs in your browser: private, instant, no account needed.

vs desktop apps: No install required. Works on any device.

vs paid tools: Completely free, unlimited use.