FormatterHQ

SVG to React Native

Turn SVG icons and illustrations into React Native components built on react-native-svg — elements renamed, attributes converted and props passed through.

Input XML
Output JSX
Ready.

How to use the SVG to React Native

  1. Paste SVG markup or upload an .svg file.
  2. Enter a Component name and tick TypeScript if needed.
  3. Copy the generated component.
  4. Install react-native-svg in your project (if you have not already) and import the component.

Convert SVG to a React Native component

React Native has no built-in SVG support; the community library react-native-svg provides components such as Svg, Path, G, Circle and LinearGradient that mirror SVG elements. This converter rewrites plain SVG markup into those components and generates the matching import line.

Example output

import * as React from 'react';
import Svg, { G, Path } from 'react-native-svg';

const HeartIcon = (props) => (
  <Svg width="24" height="24" viewBox="0 0 24 24" {...props}>
    <Path d="M20.8 4.6a5.5 5.5 0 0 0-7.8 0L12 5.7…" stroke="currentColor" strokeWidth="2" />
  </Svg>
);

export default HeartIcon;

What the converter changes

  • Element names are capitalised (path → Path) and only the components you use are imported.
  • Attributes become camelCase props (stroke-width → strokeWidth).
  • title, desc, style and script elements are removed, and class, style and xmlns attributes are dropped because react-native-svg does not use them.
  • {...props} is spread on the root Svg so you can override width, height or colour.

Colours and sizing

currentColor works in react-native-svg when you pass a color prop to the Svg component, e.g. <HeartIcon color="#e11d48" width={32} height={32} />. Keep the viewBox so the icon scales correctly.

Limitations

CSS styles inside <style> blocks, filters and some advanced SVG features are not supported by react-native-svg. Flatten styles into attributes in your design tool, and optimise the file with the SVG optimizer first. For web React, use SVG to JSX.

Using the component

import HeartIcon from './HeartIcon';

<HeartIcon width={32} height={32} color="#e11d48" />

Because props are spread onto the root Svg, any prop supported by react-native-svg — such as opacity or accessibility labels — can be passed when you render the icon. For many icons, consider generating them once and exporting them from a single file so they can be imported by name.

Test the component on both iOS and Android: some gradients, clip paths and masks render slightly differently between platforms. If an icon appears blank, check that it has a viewBox and that its colours are not set through a removed CSS class.

Installing react-native-svg

The generated component needs the react-native-svg package in your app. In an Expo project, run npx expo install react-native-svg, which picks the version that matches your Expo SDK. In a bare React Native project, run npm install react-native-svg and then cd ios && pod install so the native iOS part is linked. Rebuild the app afterwards; a fast refresh alone does not load new native code.

One component per icon, or a transformer?

Converting icons with this tool gives you plain, reviewable component files and no build configuration. If your app has dozens of icons that designers update often, react-native-svg-transformer is an alternative: after a Metro configuration change you can write import Logo from './logo.svg' and the SVG is converted at build time. Both approaches render through react-native-svg, so the limitations above apply either way.

Privacy

The tool runs entirely in your browser. Nothing you type or paste is sent to our servers.

Frequently asked questions

Do I need react-native-svg?
Yes. The generated component imports from react-native-svg, which you install with npm or yarn; in Expo projects use npx expo install react-native-svg.
Why were my CSS classes removed?
react-native-svg does not support CSS classes or style sheets inside SVG. Move colours and strokes into attributes before converting.
How do I change the icon color?
Use currentColor in the SVG and pass a color prop to the component, or override fill and stroke via props.
Is TypeScript supported?
Yes. Tick TypeScript to type props as SvgProps from react-native-svg.

Last updated October 3, 2026

Related tools

React JSX Formatter Format React components and JSX online with Prettier. SVG to Base64 Convert SVG markup or an .svg file to a Base64 data URI for CSS backgrounds, img tags and JSON. SVG to CSS Data URI Encode SVG as an optimized URL-encoded data URI for CSS background-image or mask, with a Base64 version for comparison. SVG to JPG Converter Convert SVG graphics to JPG images with a chosen background colour, scale and quality — directly in your browser. SVG to JSX / React Component Turn SVG markup into a React component: camelCase attributes, className, style objects and {...props}, with optional TypeScript. SVG to PNG Converter Convert SVG to PNG at any size or scale (2×, 4×…) with a transparent or solid background. Paste code or upload an .svg file. WEBP to JPG Converter Convert WEBP images to JPG online for free. Fast, private, in-browser conversion with preview and size comparison. WEBP to PNG Converter Convert WEBP images to PNG online for free. Fast, private, in-browser conversion with preview and size comparison. BMP to JPG Converter Convert BMP images to JPG online for free. Fast, private, in-browser conversion with preview and size comparison. BMP to PNG Converter Convert BMP images to PNG online for free. Fast, private, in-browser conversion with preview and size comparison. EXIF Remover (Strip Photo Metadata) Remove EXIF, GPS location, XMP and other metadata from photos before sharing. JPEG and PNG are cleaned losslessly, in your browser. EXIF Viewer Read EXIF, GPS, XMP, IPTC and ICC metadata from photos — camera, lens, exposure, date and location — without uploading the file.