01What is SVG to JSX?
Paste raw SVG from Figma or an icon pack straight into a React component and you usually get a console full of "Invalid DOM property" warnings, or a build that refuses to compile. This converter rewrites the markup so JSX accepts it. It follows the attribute names React documents for SVG elements, which are camelCase versions of the names in the W3C SVG specification. Here is what it actually does. A mapping table renames around forty presentation attributes, such as stroke-width, fill-rule, clip-path, stop-color, font-family and text-anchor. It also turns class into className, for into htmlFor, tabindex into tabIndex, and xlink:href or xml:space into xlinkHref and xmlSpace. Any other hyphenated attribute gets camelCased too. The data-* and aria-* attributes are left alone, because React passes them through as written. Inline style strings become style objects. Keys are camelCased, plain numbers stay numbers, vendor prefixes follow React's naming (WebkitUserSelect, msTransform) and custom properties keep their quotes. So style="opacity:0.9;--brand:red" comes out as style={{opacity: 0.9, "--brand": "red"}}. A semicolon inside url(data:...) does not split the declaration, and quotes inside values are escaped properly. Things JSX can't parse get cleaned up. The XML declaration, DOCTYPE and HTML comments are removed. CSS inside a style element is wrapped in a template literal so its braces don't confuse the JSX parser. Editor leftovers from Inkscape or Sketch, like xmlns:* declarations, sodipodi:namedview elements and inkscape: attributes, are dropped. Empty pairs such as <path ...></path> collapse into self-closing tags. A quick example: <svg class="icon" style="fill: red; stroke-linecap: round"> becomes <svg className="icon" style={{fill: "red", strokeLinecap: "round"}}>. Nothing else in the tag changes. The conversion is a set of text rewrites that run in your browser tab, so your artwork stays on your machine. That approach also sets the limits. The output is bare markup, not a component, so you still write the function, the export and any props. It doesn't optimise paths or remove hidden groups the way SVGO does. Text content and entities such as & pass through untouched. Odd hand-written markup is worth a quick look before you commit it, since the rewrites work on patterns rather than a full XML parser.
React and Next.js developers who paste icons and illustrations from design tools into components and need attributes React won't complain about. The tool runs entirely in your browser, so your data never leaves your device.
02How to use SVG to JSX
- Paste SVG markup into the SVG Input panel, or load Icon with Styles, Text with Fonts or Gradient and Filters.
- Read the converted markup in the JSX Output panel. It updates as you type.
- Compare the character counts above each panel to spot removed comments and metadata.
- Click Copy JSX.
- Wrap the result in a component, for example const Logo = (props) => (...), and spread props onto the svg element.
03Worked examples
- Input:
<svg viewBox="0 0 24 24" stroke-width="2" fill-rule="evenodd"><path d="M0 0h24"/></svg> - Result:
<svg viewBox="0 0 24 24" strokeWidth="2" fillRule="evenodd"><path d="M0 0h24"/></svg> - Hyphenated presentation attributes become camelCase. viewBox is already camelCase and stays as it is.
- Input:
<svg class="icon" style="fill: red; stroke-linecap: round"><circle cx="5" cy="5" r="4"/></svg> - Result:
<svg className="icon" style={{fill: "red", strokeLinecap: "round"}}><circle cx="5" cy="5" r="4"/></svg> - class becomes className, and the style string becomes an object with camelCase keys.
- Input:
<svg style="opacity:0.9;--brand:red;-webkit-user-select:none"><path d="M1 1"></path></svg> - Result:
<svg style={{opacity: 0.9, "--brand": "red", WebkitUserSelect: "none"}}><path d="M1 1" /></svg> - Numbers stay numeric, the custom property keeps its quotes, the vendor prefix follows React naming and the empty path self-closes.
- Input:
<svg xmlns:xlink="http://www.w3.org/1999/xlink"><use xlink:href="#a"/></svg> - Result:
<svg><use xlinkHref="#a"/></svg> - The xmlns:xlink declaration is dropped and xlink:href becomes xlinkHref.
- Input:
<?xml version="1.0"?> <svg data-id="x" aria-hidden="true" tabindex="0"><style>.a{fill:red}</style></svg> - Result:
<svg data-id="x" aria-hidden="true" tabIndex="0"><style>{`.a{fill:red}`}</style></svg> - The XML declaration goes, data-* and aria-* stay as they are, and the CSS is wrapped in a template literal.
- Input:
<svg><!-- logo --><text font-family="Arial">A & B</text></svg> - Result:
<svg><text fontFamily="Arial">A & B</text></svg> - HTML comments are removed because JSX doesn't allow them. Text content is left alone.
04Common use cases
- Turning a Figma-exported icon into an inline React component without hand-editing every attribute
- Clearing "Invalid DOM property" warnings after pasting SVG into a Next.js page
- Converting an illustration with gradients, filters and an embedded style block for a React landing page
- Stripping Inkscape or Sketch metadata from a logo before it goes into a design system package
- Migrating inline SVGs from an old HTML or Handlebars template into JSX
- Checking how an inline style string will look as a React style object, including CSS custom properties
05Tips
- Replace fixed fill colors with currentColor so the icon picks up the text color from CSS.
- Drop width and height but keep viewBox, then size the icon with CSS or a size prop.
- A style block inside the SVG stays global CSS in React. Its class names can clash with your app, so rename or scope them.
- Run large exports through SVGO first. Editors often leave redundant groups and long path precision that this tool doesn't touch.
- If you convert dozens of icons, SVGR in your build pipeline does the same job automatically.
06Related concepts
JSX, SVG, React components, SVGR, camelCase attributes.
Frequently Asked Questions
What is SVG to JSX?
SVG to JSX is a free, browser-based developer tool on AIDToolStack. Convert SVG markup to JSX components It requires no installation or sign-up and works entirely in your browser.
Is SVG to JSX free to use?
Yes. No sign-up, no fees and no usage cap.
Does SVG to JSX store my data?
No. It runs in your browser; nothing is uploaded.