Turn an SVG into a clean React component

Paste or drop an SVG and get it optimised with SVGO and written as a React component in TypeScript or JavaScript, a React Native component, clean SVG, a data URI or CSS. Preview it at every size and test currentColor live.

  • Free, no sign-up
  • Runs in your browser: Nothing you paste or drop leaves your device.

Updated 18 October 2026

SVG

Drop files here or

Preview

Paste an SVG to see it here.

Code

Code
Paste an SVG to see it here.

Icons are the easy part of a front end

I build the rest in React and Next.js, from the same Figma file I designed, so nothing gets lost between design and code.

From an SVG file to a React component

Icons and illustrations arrive from design tools as SVG files full of things a React project doesn't want: an XML declaration, editor comments, ids and groups from the layers panel, fixed widths and heights, hard-coded colours, and attributes in a form JSX can't take, like class and stroke-width. This tool takes care of all of it in one step.

Paste the SVG or drop the file. SVGO strips the editor's leftovers and tidies the paths; the converter rewrites every attribute into its JSX name (strokeWidth, className, fillRule), turns style strings into style objects, escapes text, spreads props onto the root so className, size and aria labels pass through, and names the component after the file.

currentColor and sizing

Use currentColor replaces the icon's solid colours with currentColor, so the icon takes the colour of the text it sits in: one icon works on a light button, a dark nav bar and in a hover state, with no extra code. The preview's test colour shows it live. For an icon with several colours on purpose, keep it off; the tool warns you when an SVG has more than one.

With Keep width and height off, the icon has no fixed size and fills the box your CSS gives it, keeping its proportions from the viewBox. If the SVG has no viewBox, one is made from its width and height so nothing is lost.

Accessible icons

An icon beside a text label, like an arrow in a button, should be hidden from screen readers, or they read it twice. Hide from screen readers adds aria-hidden. An icon that stands alone, like a close button with no text, needs a label instead: turn the option off and pass aria-label and role="img" as props.

React Native, data URIs and CSS

  • React Native: a component for react-native-svg, with Path, G, Circle and the rest imported by name. Style blocks, titles and class names, which React Native can't use, are left out.
  • SVG: the optimised, cleaned SVG, ready for an img tag or a sprite.
  • Data URI: the SVG written into a URL, the short URL-encoded form (smaller than base64 for SVG) and base64 for tools that need it.
  • CSS: the data URI as a background-image, for decorative icons in a stylesheet.

Safe by default

SVG can carry scripts. The converter drops script tags, event handler attributes like onload, and javascript: links before anything is shown or written, so the preview and the code are safe to use. Everything runs in your browser and nothing is uploaded. I build front ends like this in React and Next.js; for design tokens, see design tokens to Tailwind.

Questions people ask

  • Paste the SVG here, copy the React tab into a new file such as ArrowRight.tsx, and import it like any component: <ArrowRight className="size-5" />. Props such as className, width and onClick pass through to the svg element.
  • Editor metadata, comments, the XML declaration, empty groups, unused ids and needless precision in path data, using SVGO's default preset. The viewBox is always kept, so the icon still scales.
  • So the icon follows the text colour around it. Set color on a parent (or a Tailwind text-* class) and the icon changes with it, including in hover and dark mode.
  • Yes. The React Native tab writes a component for react-native-svg, with each element imported by name. Install react-native-svg in your app first.
  • The converter removes scripts, event handlers and javascript: links before showing or writing anything. Even so, only use files from sources you trust in your product.
  • Inline SVG (a component) can change colour and size with CSS and is best for interface icons. A data URI suits small decorative images in CSS. For large illustrations, a separate .svg file that the browser can cache is usually best.

Need more than a free tool?

I design and build products around jobs like this one. Start with a free 30 minute call, then get one written scope and one fixed quote.

Book a free intro call