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

Updated:

SVG to XML Converter Online

Convert SVG to XML in your browser. Paste SVG code and get an Android vector drawable you can drop into res/drawable, or switch the option off for a clean, formatted XML file. Your code is never uploaded.

Options:

SVG

Input
0 chars · 0 lines

XML

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

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 XML

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

  1. 01

    Paste your SVG

    Paste the SVG code into the left panel. The Sample button loads a small icon with a rounded square, a circle and a line path so you can see the output first.

  2. 02

    Choose the kind of XML

    Leave Android vector drawable on to get a <vector> file for Android Studio. Switch it off to get your SVG as a clean, indented XML file with an XML declaration.

  3. 03

    Check for notes

    If the SVG uses something the Android format cannot hold, such as text, images or gradients, a comment at the top of the result lists what was left out. Fix those parts in your SVG editor and convert again.

  4. 04

    Copy or download

    Copy the XML or download it. For Android, save it as a .xml file in the res/drawable folder of your project. The swap button sends the result to XML to SVG so you can check it round-trips.

What SVG to XML Means

Every SVG is already an XML document, so the answer to svg to xml depends on what you need. Most developers searching for it want an Android vector drawable, the XML format that Android uses for scalable icons. Others only want their SVG written as tidy XML with a declaration, which some tools and parsers expect. This converter does both with one switch.

  • Android vector drawable: a <vector> file that goes into res/drawable and works with ImageView, Jetpack Compose and Material components.
  • Formatted XML: the same SVG, re-indented and starting with <?xml version="1.0" encoding="utf-8"?>.

How SVG Maps to an Android Vector Drawable

A vector drawable has a smaller vocabulary than SVG, so the tool translates each SVG feature into the closest Android one:

  • Size: the SVG width and height become android:width and android:height in dp, and the viewBox becomes viewportWidth and viewportHeight.
  • Shapes: rect, circle, ellipse, line, polyline and polygon are rewritten as path data, since Android only draws paths.
  • Colours: fill and stroke become fillColor and strokeColor. Named colours, short hex codes and rgb() values are converted. Opacity becomes fillAlpha and strokeAlpha.
  • Stroke and fill details: width, line cap, line join, miter limit and the even-odd fill rule are carried over.
  • Transforms: translate, scale, rotate and scale-and-translate matrices become nested <group> elements. Skew is not supported on Android.

Using the Result in Android Studio

  1. Save the output as a file such as ic_logo.xml and put it in app/src/main/res/drawable.
  2. Reference it with @drawable/ic_logo in a layout, or painterResource(R.drawable.ic_logo) in Jetpack Compose.
  3. To recolour an icon from code or a theme, remove the fillColor from the path and use a tint.

Need the opposite direction, for example to preview a drawable from a project or send it to a designer? XML to SVG converts a vector drawable back to a standard SVG. To turn an SVG into a PNG for app store listings, use SVG to PNG, and to turn a logo picture into an SVG first, try PNG to SVG.

Formatted XML for Other Uses

With the Android option off, the tool parses your SVG, checks that it is well-formed and writes it back with two-space indentation and an XML declaration. This helps when a build step, a legacy importer or a code review needs readable XML. The content of the SVG is not changed. Text inside elements such as <text> and <style> is kept exactly as written.

Frequently Asked Questions

Technical Q&A for SVG to XML

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

No. The conversion runs in your browser tab. Your SVG is never sent to ToolPlank or anyone else.

Yes. Save it as an .xml file in res/drawable. If the SVG used features Android does not support, a comment at the top of the file lists them. Android Studio also has a built-in Vector Asset importer; this tool is useful when you want to convert code you already have.

The Android vector drawable format has no equivalent for text, images or filters, and this converter does not translate SVG gradients. They are listed in the comment at the top of the output. Convert text to outlines and use flat colours.

On, the output is a <vector> file for Android. Off, the output is your SVG as indented XML with an XML declaration. The drawing itself is unchanged.

Yes. XML to SVG converts an Android vector drawable back to a standard SVG, including groups, gradients and clip paths.