SVG to JSX converter

Paste any SVG and get a typed React component: camelCase props, style objects, currentColor and optimized markup. Free, no sign up, runs in the browser.

Converting...

Output
Preview
No preview
CheckIcon.tsxtsx
// Converting...

How to use it

  1. 1Paste the SVG markup, straight from Figma, Illustrator or an icon set.
  2. 2Name the component and pick TypeScript or JavaScript.
  3. 3Decide whether to spread props, use currentColor and optimize away editor data.
  4. 4Copy the component into your project.

What changes between SVG and JSX

Browsers read SVG as XML, so attributes are hyphenated and the style attribute is a string. React expects props: stroke-width becomes strokeWidth, class becomes className, xlink:href becomes xlinkHref, and style="fill:red" becomes style={{ fill: "red" }}. Empty elements such as <path></path> self close, and the XML declaration, doctype and comments go away because JSX has no use for them. The converter parses the markup with the browser's own parser, never with eval or innerHTML, and writes the JSX by hand, so nothing you paste can run on this page. The preview is an image built from the markup, which is why it cannot execute scripts either.

The options

  • Spread props removes the fixed width and height from the root and adds {...props}, so <Icon className="size-4" /> sizes the icon from CSS. The viewBox stays, since it is what makes scaling work.
  • Use currentColor swaps fill and stroke colours for currentColor, so the icon follows the text colour, including in dark mode. Gradients, none and url() references are left alone.
  • Optimize removes ids nothing references, <metadata>, Inkscape and Illustrator namespaces, xml:space and similar export residue, and collapses whitespace in attributes. Ids used by url(#id) or href="#id" are kept, so gradients and clip paths keep working.
tsx
import type { SVGProps } from "react"

export function CheckIcon(props: SVGProps<SVGSVGElement>) {
  return (
    <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" {...props}>
      <path d="M8 12.5l2.5 2.5L16 9.5" stroke="currentColor" strokeWidth={1.5} strokeLinecap="round" />
    </svg>
  )
}

What the tool does not do

This is a converter, not an optimizer like SVGO: path data is not rewritten and shapes are not merged. It does not rename ids either, so two converted icons on one page that both use id="glow" will clash. For a build-time workflow with those features use SVGR; the output here follows the same conventions, so switching later is painless.

Frequently asked questions

Is the SVG uploaded anywhere?

No. Parsing and conversion run in your browser with the standard DOM parser, and the preview is an image built from the markup. Nothing is sent to a server.

Why did my gradient or clip path stop working?

Usually because an id was removed. The optimizer keeps ids referenced by url(#id) or href="#id" inside the same file; references from external CSS cannot be seen, so turn optimize off in that case.

Can I convert many icons at once?

Not here, one SVG at a time. For a folder of icons use SVGR in your build; this tool follows its conventions, so the components look the same.