SVG to JSX
Convert SVG markup into clean React JSX or TSX components
Drop an .svg file here
SVG files up to 5 MB.
You can also paste from the clipboard.
PascalCase, for example ArrowRightIcon.
Renders an optional <title> linked through titleId.
Removes comments and whitespace-only text between elements. This is a safe cleanup, not a full SVG optimizer.
More options
Turn off for decorative icons: title, desc, role and ARIA attributes are removed and aria-hidden is added.
Replaces the root title and adds role="img".
Paste SVG markup or upload a file to see the preview.
How to use it
- 1.Paste SVG markup, drop or browse for an .svg file, or load the example.
- 2.Check the sanitized preview and the list of removed unsafe items.
- 3.Choose the target (React JSX, React TSX, React Native, or a bare JSX fragment) and set the component name.
- 4.Toggle spread props, memo, forwardRef, the title prop, width/height removal, currentColor, and the optimization level as needed.
- 5.Copy the code or download it as a .jsx or .tsx file.
What SVG to JSX does
SVG to JSX turns SVG markup into a React component or a plain JSX element. Attributes are mapped to their React names (class → className, stroke-width → strokeWidth, fill-rule → fillRule, clip-path → clipPath, xlink:href → xlinkHref), inline style strings become style objects, and the viewBox is always preserved so the icon keeps scaling correctly.
Options explained
Spread props forwards className, size, and event props from the component to the root <svg>; TSX adds an SVGProps<SVGSVGElement> type. Removing width and height lets CSS control the size through the viewBox. currentColor replaces solid fill and stroke colors so the icon inherits the text color, while none, transparent, gradients (url(...)), and CSS variables stay untouched. Safe cleanup (Optimization) removes comments and whitespace-only text between elements; it is a safe cleanup, not a full SVG optimizer. Turn off accessibility attributes for decorative icons to remove title, desc, role, and ARIA and add aria-hidden, or enter a title to label meaningful icons with role="img".
React Native output
The React Native target emits a react-native-svg component and imports only the components the icon uses, such as Svg, G, Path, Circle, Rect, Ellipse, Line, Polygon, Polyline, Defs, LinearGradient, RadialGradient, Stop, ClipPath, Mask, Pattern, Use, Symbol, Text, TSpan and Image. Attributes are camelCased, xlink:href becomes href, and supported style declarations such as fill or stroke-width become props. Classes, CSS style blocks, filters such as feGaussianBlur, foreignObject, animations, scripts and event handlers cannot work in React Native, so they are dropped and listed as warnings below the code. Width and height come from component props (typed as SvgProps in TSX), and a title becomes accessibilityLabel. Memo, forwardRef and the title prop work for React and React Native. Safe cleanup shows the SVG size before and after optimization.
Security and limits
Every input is sanitized before preview and conversion: <script>, <foreignObject>, event handlers such as onclick, javascript: URLs, external image or resource references, and unsupported elements are removed and reported. DOCTYPE declarations and XML entities are rejected. The preview renders only the sanitized markup as an image, so nothing in the SVG can run. SVG text is limited to 5 MB. Because unsupported elements are dropped, compare the preview with your original when converting complex illustrations.
Frequently asked questions
- Does the converter run scripts or event handlers from my SVG?
- No. Every input is sanitized first: script and foreignObject elements, on* event attributes, javascript: URLs, and external references are removed and listed. The preview shows only the sanitized markup as an image.
- What is the difference between JSX and TSX output?
- Both produce the same markup. TSX output with spread props imports the SVGProps type and types the props parameter as SVGProps<SVGSVGElement>, and the file downloads with a .tsx extension.
- Which colors does the currentColor option replace?
- Solid fill and stroke values in attributes or inline styles are replaced with currentColor. none, transparent, gradient or pattern references such as url(#id), and CSS variables are left unchanged.
- Is the output optimized like SVGO?
- No. The cleanup option removes comments and whitespace-only text between elements. Path data, precision, and element structure are not rewritten, so run a dedicated optimizer first if you need smaller paths.
