React Native output
SVG to React Native
Paste or upload an SVG and download a component for a React Native project. The file imports react-native-svg. It is not a web component.
The root element is Svg, with width and height props defaulted from the file. TypeScript annotates those props as SvgProps. The preview under the tool is the sanitized web SVG, drawn in this browser.
React Native component
For React Native projects, not the web. Your SVG is not uploaded.
Waiting for an SVG
Language
TypeScript annotates the props as SvgProps from react-native-svg. JavaScript is the same component without that type.
Limit 500 KB and 10,000 elements. The download is a React Native component that imports react-native-svg. Scripts are removed before the file is created.
React Native component
This result is for a React Native project, not a web page. Use it in an app that depends on react-native-svg.
The React Native component will appear here. It is for a React Native project, not a web page.
What the file contains
SVGR prints the component with native mode on. Elements such as path and rect become Path and Rect, imported from react-native-svg. A TypeScript file also imports the SvgProps type from that package. The classic JSX runtime adds import * as React from 'react'. Width and height are component props, and the same values are passed to the root Svg.
Need a web component instead? Use the converter, the JSX page, or the TSX page. Those pages emit an svg element. Vue and Svelte files are on SVG to Vue and SVG to Svelte. The optimizer, PNG export, and data URI tools are separate.
Example
This pair is the attribute demo run through the same React Native converter as the tool above. The language is TypeScript and the component name is IconPath. Formatting is on.
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"> <path class="icon" fill-rule="evenodd" clip-rule="evenodd" stroke-width="2" stroke-linecap="round" d="M4 12h16"/> </svg>
import * as React from 'react';
import Svg, { Path } from 'react-native-svg';
import type { SvgProps } from 'react-native-svg';
const IconPath = ({ width = 24, height = 24, ...props }: SvgProps) => (
<Svg
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 24 24"
width={width}
height={height}
{...props}
>
<Path
className="icon"
fillRule="evenodd"
clipRule="evenodd"
strokeWidth={2}
strokeLinecap="round"
d="M4 12h16"
/>
</Svg>
);
export default IconPath;Limits
- 500 KB per SVG. Larger files are rejected and are not converted.
- 10,000 elements. A larger tree is rejected.
- The SVG is sanitized before SVGR runs. A failed sanitize produces no file.
- Scripts, event handlers, and embedded HTML are removed. Warnings list those removals.
- Names that match a react-native-svg import, such as Svg or Path, are rejected.
- The copy and download actions use the React Native component. The original input is not offered as a file.
- The app that imports the file needs the react-native-svg package. This site does not install it.
Questions
Is my SVG uploaded?
No. Sanitizing and the React Native component are built in this browser tab. The SVG is not sent to a server, saved in a database, or sent to analytics. Copy and download stay on your device. Closing the tab discards the file.
Is this component for the web?
No. The result is for React Native projects, not the web. It imports Svg and the other elements from react-native-svg. The homepage, JSX, and TSX tools still emit a web svg element. Install react-native-svg in the app that imports this file.
What does the preview show?
The preview is the sanitized web SVG in a frame with scripts disabled. It is labeled as a web preview. It does not mount react-native-svg, and it does not run the generated component.
Do scripts stay in the component?
No. The same sanitizer as the converter runs before SVGR. Scripts, event handlers, and embedded HTML are removed. Warnings list what was removed. If the SVG cannot be sanitized, the page does not create a component and does not offer the original markup as a download.