Table of Contents
CLI Tool
Overview
A command-line tool to convert SVG or Android Vector Drawable (AVG) files into Jetpack Compose ImageVector code. Built with Kotlin Native, it runs natively on macOS, Linux, and Windows without requiring a JVM.Key features:
- Converts SVG and Android Vector Drawables to ImageVector
- Optional SVG optimization via SVGO and Avocado
- Supports batch conversion of entire directories
- Material Icons receiver type support
- KMP-compatible output generation
Platform Support
The CLI tool supports the following platforms:
| Platform | With optimization | Without optimization |
|---|---|---|
| macOS Arm64 | ||
| macOS x64 | ||
| Linux x64 | ||
| Windows (mingwX64) | ||
| Windows (WSL) |
Installation
1. Download the latest release binary for your platform from the GitHub releases page, then give it execution permission:
2. Add the binary to your PATH:
External Dependencies
When optimization is enabled (the default), the CLI uses SVGO for SVG optimization and Avocado for Android Vector Drawable optimization. Both require Node.js.
Install the optimization tools globally:
If you do not have Node.js installed or do not need optimization, you can disable it with the
-opt false flag.
Usage Examples
Convert a single SVG file:
Batch convert a directory recursively:
Generate with a Material Icons receiver type:
Convert an Android Vector Drawable (AVG/XML):
Disable optimization:
All Options Reference
The following table lists all available CLI flags:
Output Examples
The CLI generates Kotlin files containing ImageVector builders. Each icon is exposed as a lazily-initialized property with a backing field for caching.
The generated code uses the same
ImageVector.Builder API that Jetpack Compose uses internally, ensuring full compatibility.
MyIcon.kt