Frequently Asked Questions

What is SVG to Compose?

SVG to Compose is a Kotlin Multiplatform tool that converts SVG and Android XML Drawable files into Jetpack Compose ImageVector code. It eliminates the manual, error-prone process of hand-writing ImageVector builder code. Available as a CLI tool, a Gradle plugin, and a library.

How to Convert

Install the CLI tool and run:
Copy
For automated build integration, use the Gradle plugin instead. Both approaches use the same conversion engine.

Does it support Android XML Drawables?

Yes. Pass an .xml file instead of .svg. The parser handles Android Vector Drawable XML format including path data, groups, gradients, and clip paths.

Can I use it in a Kotlin Multiplatform project?

Yes. SVG to Compose is built with Kotlin Multiplatform. The core library targets JVM, JS, WASM/JS, macOS, Linux, and Windows. Generated code uses Jetpack Compose's ImageVector API which works across all Compose targets. Use the --kmp flag with the CLI for KMP-compatible output.

What SVG features are supported?

Supported features include all path commands, basic shapes, groups with transforms, linear and radial gradients, clip paths, fill and stroke styling, viewBox, and opacity. Not yet supported: filters, masks, patterns, text elements, and animations.

How does the Gradle plugin differ from the CLI?

The Gradle plugin integrates conversion into your build pipeline with incremental build support, smart caching, and parallel processing. It automatically re-converts when source files change. The CLI is a standalone tool for one-off conversions or CI scripts.

Is the generated code optimized?

Yes. SVG to Compose integrates with SVGO for SVG optimization and Avocado for XML Drawable optimization to optimize vector paths before code generation. The generated ImageVector uses lazy initialization with a backing field for efficient caching.Install the optimization tools globally:
Copy
For more details, see the CLI documentation section on external dependencies.