Skip to content
ToolPlankDEV
Image & SVG Tools
100% In-Browser Execution

Updated:

SVG to JSX Converter

Convert SVG to JSX in your browser. Paste SVG code and get markup React accepts, with stroke-width as strokeWidth, class as className and style strings as objects, or a ready React component in JavaScript or TypeScript. Nothing is uploaded.

Options:

Name and props apply when Output is a component.

SVG

Input
0 chars · 0 lines

JSX

Ready
Processing in browser...
0 chars · 0 linesUpdates as you type

Preview of your SVG

A preview of the SVG appears here. Scripts and event handlers are never run.

What changed

Renamed attributes and removed parts are listed here.

Processed on your device. Your text is not sent to our servers.

More free tools you may need next.

Quick Guide

How to use SVG to JSX

Simple step-by-step instructions to get the exact output you need.

  1. 01

    Paste or upload the SVG

    Paste SVG code into the SVG box or upload an .svg file. A preview of the image appears under the editors.

  2. 02

    Choose the output

    JSX only gives the markup. React component and TypeScript component wrap it in a component with the name you type.

  3. 03

    Set the clean-up options

    Remove width and height, use currentColor for fill and stroke, and remove editor data. The What changed box lists every rename and removal.

  4. 04

    Copy or download

    Press Copy, or Download to save a .jsx or .tsx file.

Convert SVG to JSX for React

SVG pasted straight into React gives warnings such as Invalid DOM property class and stroke-width. JSX wants class as className, hyphenated attributes in camelCase, and style as an object. This SVG to JSX converter makes those changes. The Sample:

xml
<?xml version="1.0" encoding="UTF-8"?>
<!-- Exported from a design tool -->
<svg xmlns="http://www.w3.org/2000/svg" class="icon" width="24" height="24" viewBox="0 0 24 24">
  <circle cx="12" cy="12" r="9" fill="none" stroke="teal" stroke-width="2"/>
  <path data-name="check" d="M8 12.5l2.5 2.5L16 9.5" fill="none" stroke="teal" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="opacity: 0.9"/>
</svg>

becomes:

jsx
<svg
  xmlns="http://www.w3.org/2000/svg"
  className="icon"
  width="24"
  height="24"
  viewBox="0 0 24 24"
>
  <circle cx="12" cy="12" r="9" fill="none" stroke="teal" strokeWidth="2" />
  <path
    d="M8 12.5l2.5 2.5L16 9.5"
    fill="none"
    stroke="teal"
    strokeWidth="2"
    strokeLinecap="round"
    strokeLinejoin="round"
    style={{ opacity: "0.9" }}
  />
</svg>

The XML declaration, the comment and the data-name attribute are removed, and 5 attributes are renamed.

What Gets Renamed

  • class to className, for to htmlFor, tabindex to tabIndex.
  • Hyphenated attributes to camelCase: stroke-width to strokeWidth, fill-rule to fillRule, clip-path to clipPath, stop-color to stopColor.
  • xlink:href to xlinkHref, xml:space to xmlSpace, xmlns:xlink to xmlnsXlink.
  • style="fill: red; stroke-width: 2" to style={{ fill: "red", strokeWidth: "2" }}.
  • Text with { or } is escaped so JSX does not read it as code, and the contents of a <style> element become a template string.

data-* and aria-* attributes stay as they are, and attributes that are already camelCase in SVG, such as viewBox and gradientUnits, are not touched.

Make a React Component

Set Output to TypeScript component, type a name, and switch on Remove width and height and Use currentColor. The Sample becomes:

tsx
import type { SVGProps } from "react";

const CheckCircle = (props: SVGProps<SVGSVGElement>) => (
  <svg xmlns="http://www.w3.org/2000/svg" className="icon" viewBox="0 0 24 24" {...props}>
    <circle cx="12" cy="12" r="9" fill="none" stroke="currentColor" strokeWidth="2" />
    <path
      d="M8 12.5l2.5 2.5L16 9.5"
      fill="none"
      stroke="currentColor"
      strokeWidth="2"
      strokeLinecap="round"
      strokeLinejoin="round"
      style={{ opacity: "0.9" }}
    />
  </svg>
);

export default CheckCircle;

Because of {...props} you can write <CheckCircle className="size-6 text-teal-600" aria-label="Done" />. With currentColor the icon takes the text color of its parent, and without width and height CSS controls its size.

Safe Output

<script> elements, event attributes such as onclick or onload, and links that start with javascript: are always removed from the output. Editor attributes such as inkscape:label and sodipodi:docname are removed because React cannot render namespaced attributes. The preview is drawn as an image, so scripts in the SVG never run.

Going the Other Way and Other SVG Tools

Turn JSX back into a plain file with JSX to SVG, or press the swap button. To get an image from the same code use SVG to PNG, and for Android use SVG to XML.

Privacy

The conversion runs in your browser. Your SVG is not uploaded. See the Privacy Policy.

Frequently Asked Questions

Technical Q&A for SVG to JSX

Common questions about edge cases, character encoding, and privacy guarantees.

Paste the SVG here, copy the JSX and place it in your component's return. Or pick React component and import the generated file like any other component.

React expects DOM properties in camelCase, so stroke-width must be strokeWidth and class must be className. The converter renames them for you.

Switch on Use currentColor. Fill and stroke colors become currentColor, so the icon uses the CSS color of its parent. none and url() fills such as gradients stay.

Inline JSX lets you change color and size with props and CSS and needs no extra request. A file is better for large or rarely used images, since it can be cached and keeps your bundle smaller.

No. React Native needs the react-native-svg library, which uses its own components such as <Path> instead of <path>.

No. Everything runs in your browser.