Skip to main content

SVG to React & JSX Converter

Convert raw SVG markup into clean React, Vue, Svelte, and TSX components

Presets:
SVG Live Render:
Component Output Code
import React, { SVGProps } from 'react';

export const IconCheckCircle = (props: SVGProps<SVGSVGElement>) => (
  <svg {...props} xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="#10b981" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" className="feather feather-check-circle">
  <path d="M22 11.08V12a10 10 0 1 1-5.93-9.14"></path>
  <polyline points="22 4 12 14.01 9 11.01"></polyline>
</svg>
);

export default IconCheckCircle;

Was this SVG to React & JSX Converter helpful?

Help us keep tools reliable, fast, and bug-free.

What you can do with SVG to React & JSX Converter

  • Convert svg to react
  • Transform svg to tsx component

What this conversion does

Convert raw SVG markup into a ready-to-use React component with JSX-compatible attributes.

Example input

<svg viewBox="0 0 24 24"><path fill-rule="evenodd" d="M4 12h16"/></svg>

Example output

import React, { SVGProps } from 'react';

export const IconCheckCircle = (props: SVGProps<SVGSVGElement>) => (
  <svg {...props} viewBox="0 0 24 24"><path fillRule="evenodd" d="M4 12h16"/></svg>
);

export default IconCheckCircle;

Practical workflow

  1. Paste the SVG markup exported from your design tool or icon set.
  2. Name the component and choose JavaScript or TypeScript output.
  3. Copy the generated component — kebab-case attributes are converted to camelCase JSX automatically.

Common use cases

  • Turn design-tool icon exports into typed React components.
  • Convert one-off illustrations into components that accept props like className and size.
  • Migrate inline SVG snippets from HTML templates into a React codebase.

Important notes and limitations

  • The live preview sanitizes input to a limited set of passive SVG shapes and attributes; scripts, embedded HTML, external image references, and event handlers are removed.
  • Conversion runs locally in the browser. The generated code is a starting point; review SVG content before adding it to a production application.
  • React, Vue, and Svelte outputs use different component conventions. The converter does not install framework dependencies or compile the generated component.

SVGR CLI & SVG component transformation

Convert SVG to TypeScript React component with @svgr/cli

npx @svgr/cli --icon --typescript --memo icon.svg

Converts raw SVG into an accessible, memoized React component supporting className and SVGProps.

Batch convert SVG icons directory to React components

npx @svgr/cli --out-dir src/components/icons --ext tsx assets/svg

Compiles an entire folder of SVG assets into clean, tree-shakeable React icon components.

JSX attribute syntax & viewBox preservation

Invalid DOM property 'class' / 'stroke-width' in JSX

Cause: Raw SVG uses HTML/XML attribute names instead of React camelCase properties ('className', 'strokeWidth').

Solution: Transform SVG through SVGR or replace kebab-case SVG attributes with standard camelCase JSX properties.

SVG scales incorrectly or clips when resizing in React

Cause: SVG has hardcoded 'width' and 'height' attributes but omits the responsive 'viewBox' attribute.

Solution: Ensure 'viewBox="0 0 W H"' is present, and set 'width="1em" height="1em"' or 'w-full h-full' in CSS.

Continue your workflow

Frequently asked questions

How do I use an SVG file as a React component?

Paste the SVG markup and the converter renames kebab-case attributes (fill-rule, stroke-width, class) to their JSX equivalents (fillRule, strokeWidth, className) and wraps everything in an exported component you can import like any other.

Can it output TypeScript?

Yes. Choose React (TypeScript / TSX) from Target Framework to generate a component typed with SVG props.

Why are my SVG attributes invalid in JSX?

JSX requires camelCase attribute names, so raw SVG attributes like fill-rule cause errors. The converter performs that renaming for every attribute automatically.