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:
Copy
2. Add the binary to your PATH:
Copy

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.
If you do not have Node.js installed or do not need optimization, you can disable it with the -opt false flag.
Install the optimization tools globally:
Copy

Usage Examples

Convert a single SVG file:
Copy
Batch convert a directory recursively:
Copy
Generate with a Material Icons receiver type:
Copy
Convert an Android Vector Drawable (AVG/XML):
Copy
Disable optimization:
Copy

All Options Reference

The following table lists all available CLI flags:
FlagTypeDescription
-o, --outputStringOutput file or directory path
-p, --packageStringKotlin package name for generated code
-t, --themeStringFully-qualified theme class name
-opt, --optimizeBooleanEnable SVG/AVG optimization (default: true)
-rt, --receiver-typeStringReceiver type (e.g. Icons.Filled)
--add-to-materialBooleanAdd as extension to Material Icons
-np, --no-previewBooleanSkip generating @Preview composables
--kmpBooleanEnsure output is KMP-compatible (default: false)
--make-internalBooleanMark generated symbols as internal
--minifiedBooleanRemove comments and inline method parameters
-r, --recursiveBooleanRecursively process sub-directories
--recursive-depth, --depthIntDepth level for recursive search (default: 10)
--excludeString...Regex pattern to exclude icons from processing
--map-icon-name-from-toPair...Replace icon name pattern (old to new)

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
Copy