SVG to JSX Converter

Convert SVG into a React component. Paste an icon and get JSX or TypeScript with attributes camelCased, className and style objects fixed, props spread onto the root and, if you like, the fixed size removed so CSS can scale it. Drop a whole folder of icons to get one component per file plus an index, as a ZIP. It's free, runs in your browser, and nothing is uploaded.

Attribute conversions

SVGJSX
classclassName
stroke-width="2"strokeWidth={2}
fill-rulefillRule
clip-pathclipPath
xlink:hrefxlinkHref
style="fill:red"style={{ fill: "red" }}

When to use it

  1. Turn designer-exported SVG icons into React components.
  2. Build an icon library from a folder of SVGs.
  3. Fix the attribute errors from pasting raw SVG into JSX.
  4. Make icons that take className, size and color props.

How to Use

  1. Paste SVG markup.
  2. Set the component name and choose TypeScript, props spreading and size removal.
  3. Copy the component — or drop a folder of SVGs and download them all.

Features

  1. camelCased SVG attributes
  2. TypeScript or JavaScript
  3. Props spreading
  4. Optional size removal
  5. Batch conversion with index file
  6. Rejects malformed SVG
  7. 100% client-side

FAQs

Why can't I paste SVG straight into JSX?

Attributes like stroke-width, fill-rule and class must be strokeWidth, fillRule and className in React.

What does spreading props do?

Passing {...props} to the svg lets you set className, width, aria-label or onClick when you use the icon.

Should I remove width and height?

Yes, if you want to size icons with CSS. Keep viewBox so it scales correctly.

Can I convert many icons at once?

Yes. Drop a folder of SVGs to get a ZIP with one component per icon and an index file.

Is my SVG uploaded?

No. Conversion happens in your browser.

Technical Details

The SVG is parsed with the browser's XML parser, which rejects malformed markup instead of guessing, and walked into JSX. Hyphenated presentation attributes become camelCase (stroke-width to strokeWidth, fill-rule to fillRule, clip-path to clipPath), namespaced ones follow React's names (xlink:href to xlinkHref, xmlns:xlink to xmlnsXlink), class becomes className, inline styles become objects, and data- and aria- attributes are left alone. Purely numeric values are written as numbers in braces, which is how hand-written icon components usually look. The result is wrapped in a function component, optionally typed with React.SVGProps<SVGSVGElement>, with {...props} spread on the root after the other attributes so callers can override them, and with the fixed width and height removable so the icon scales with CSS. A whole folder of SVGs can be converted at once: file names become PascalCase component names ending in Icon, and the ZIP includes an index file that re-exports them all.

Developer Tools

Developer Tools

  • Data URI Generator & Decoder
  • SVG to CSS Converter
  • CSS Data URI Converter
  • Basic Auth Header Generator
  • Hex Dump Viewer
  • Text Encoding Inspector
  • Punycode Converter
  • Email Obfuscator