Convert SVG to codeYour SVG, ready to paste as code

Drop an SVG and copy it as a data URI, CSS, React or a sprite — each with its size.

Convert SVG to code: optimised markup, URL-encoded and base64 data URIs, CSS background, React JSX, React Native and a symbol sprite, with sizes. Made on your device.

  • Optimised SVG markup
  • URL-encoded and base64 data URIs with byte counts
  • CSS background-image
  • React JSX and React Native (react-native-svg)
A round star logo: the left half is the original bitmap, the right half is the traced SVG with smooth edges

Open an SVG to turn into code

Drop an .svg file, paste SVG code anywhere on the page, or choose a file. The code is made on this device.

SVG to code

Get an SVG in every form developers paste: optimised markup, URL-encoded and base64 data URIs, a CSS background, a React component, React Native code and a sprite symbol — each with its size and a copy button.

Pick the form that fits where it goes

Inline markup is best when you want to colour or animate the icon with CSS. A data URI suits a background image or a single <img> without an extra file. A React component keeps icons in your component library. A sprite sheet lets one hidden <svg> serve every copy of an icon on the page.

Smaller before it is code

With Optimise first on, numbers are rounded to two decimals and editor leftovers (metadata, comments, empty groups) are removed before conversion, so every form is as short as it can be. Turn it off to keep the markup exactly as it came, apart from the safety clean-up.

Sizes you can compare

Every output shows its byte count, so you can see what inlining costs. Over about 10 KB, an inlined SVG starts to weigh on the CSS or HTML that carries it; a separate .svg file that the browser caches is usually the better choice then.

Related SVG tools

SVG to code questions

Base64 or URL-encoded — which data URI should I use?

URL-encoded, in almost every case. SVG is text, and URL-encoding keeps it as text with a few characters escaped, so it is usually smaller than base64 (which adds about a third) and it compresses better with gzip or Brotli. Use base64 only where a tool or email client insists on it. Both sizes are shown next to each other.

How do I use the React component?

Paste it into a .tsx or .jsx file and render <VectorArt /> (named after your file). Attributes are already converted for JSX — className, strokeWidth, fillRule — and any props you pass, such as width, className or aria-label, go onto the <svg>.

What does the React Native version need?

The react-native-svg package, which provides Svg, Path, Circle and the other elements. The converter maps each SVG tag to its react-native-svg component and lists anything it had to drop, such as <title> or <style>, which react-native-svg has no equivalent for.

Can I turn SVG code back into an image?

Yes. Paste the code into the box under the drop area and choose Show the picture. You see it rendered at once and can save it as a PNG, or open the SVG to PNG tool for an exact pixel size.

Is the code safe to paste into my site?

Scripts, event handlers and links to outside files are removed before anything is shown or converted, and the output is checked again after optimising. The page says what was removed, if anything.