{"id":28119315,"url":"https://github.com/rafaeltonholo/svg-to-compose","last_synced_at":"2026-03-08T22:02:27.465Z","repository":{"id":176954632,"uuid":"659782425","full_name":"rafaeltonholo/svg-to-compose","owner":"rafaeltonholo","description":"A command-line tool and a Gradle Plugin for convert SVG to Android Jetpack Compose Icons.","archived":false,"fork":false,"pushed_at":"2026-03-05T03:35:08.000Z","size":2265,"stargazers_count":155,"open_issues_count":13,"forks_count":5,"subscribers_count":2,"default_branch":"main","last_synced_at":"2026-03-05T08:24:36.044Z","etag":null,"topics":["android","android-drawables","compose-jb","compose-multiplatform","gradle-plugin","icons","jetpack-compose","kmp","kotlin","svg"],"latest_commit_sha":null,"homepage":"","language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rafaeltonholo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2023-06-28T14:47:27.000Z","updated_at":"2026-03-05T03:05:22.000Z","dependencies_parsed_at":null,"dependency_job_id":"12dd610e-f598-4aad-b965-a6aceab03546","html_url":"https://github.com/rafaeltonholo/svg-to-compose","commit_stats":null,"previous_names":["rafaeltonholo/svg-to-compose"],"tags_count":14,"template":false,"template_full_name":null,"purl":"pkg:github/rafaeltonholo/svg-to-compose","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rafaeltonholo%2Fsvg-to-compose","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rafaeltonholo%2Fsvg-to-compose/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rafaeltonholo%2Fsvg-to-compose/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rafaeltonholo%2Fsvg-to-compose/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rafaeltonholo","download_url":"https://codeload.github.com/rafaeltonholo/svg-to-compose/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rafaeltonholo%2Fsvg-to-compose/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30274876,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-08T20:45:49.896Z","status":"ssl_error","status_checked_at":"2026-03-08T20:45:49.525Z","response_time":56,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["android","android-drawables","compose-jb","compose-multiplatform","gradle-plugin","icons","jetpack-compose","kmp","kotlin","svg"],"created_at":"2025-05-14T07:17:23.747Z","updated_at":"2026-03-08T22:02:27.458Z","avatar_url":"https://github.com/rafaeltonholo.png","language":"Kotlin","funding_links":[],"categories":[],"sub_categories":[],"readme":"# SVG to Compose\n\n[![Built with KMP](https://img.shields.io/badge/Built_with_KMP-gray?logo=kotlin)](https://kotlinlang.org/docs/multiplatform.html)\n[![SVG to Compose Latest version](https://img.shields.io/maven-central/v/dev.tonholo.s2c/svg-to-compose?display_name=tag\u0026label=svg-to-compose\u0026logo=apachemaven)](https://central.sonatype.com/artifact/dev.tonholo.s2c/svg-to-compose)\n[![SVG to Compose Gradle Plugin Latest version](https://img.shields.io/maven-central/v/dev.tonholo.s2c/svg-to-compose-gradle-plugin?display_name=tag\u0026label=svg-to-compose-gradle-plugin\u0026logo=apachemaven)](https://central.sonatype.com/artifact/dev.tonholo.s2c/svg-to-compose-gradle-plugin)\n[![LICENSE](https://img.shields.io/github/license/rafaeltonholo/svg-to-compose)](./LICENSE)\n\nA suite of tools to convert SVG or Android Vector Drawable (AVD/XML) files into\nAndroid Jetpack Compose Icons. This project provides:\n\n- A **command-line tool** for manual conversion.\n- A **Gradle plugin** for automating the conversion within your build process.\n\n---\n\nFor more detailed information on each tool, configurations, and features, please\nrefer to the full documentation:\n\n- [Command-line Tool Documentation](./svg-to-compose/README.md)\n- [Gradle Plugin Documentation](./svg-to-compose-gradle-plugin/README.md)\n\n---\n\n## Table of Contents\n\n- [Why?](#why)\n- [Platform Support](#platform-support)\n- [Available Tools](#available-tools)\n    - [Command-line Tool](#command-line-tool)\n    - [Gradle Plugin](#gradle-plugin)\n- [Getting Started](#getting-started)\n    - [Command-line Tool Installation](#command-line-tool-installation)\n    - [Gradle Plugin Installation](#gradle-plugin-installation)\n- [Usage](#usage)\n    - [Using the Command-line Tool](#using-the-command-line-tool)\n    - [Using the Gradle Plugin](#using-the-gradle-plugin)\n- [Contributing \u0026 Community](#contributing--community)\n- [License](#license)\n\n## Why?\n\nWith the introduction of Jetpack Compose, Android developers can leverage the\nfull power of Kotlin to build UI components, moving away from traditional XML\nlayouts. However, integrating vector assets like icons often still relies on\nusing Android Vector Drawables (AVD/XML) resources.\n\nThis project aims to streamline the integration of vector assets into Compose\napplications by providing tools that convert SVG or AVD files directly into\nCompose `ImageVector` objects, following the same approach used for Google's\nMaterial Icons.\n\n**Key Advantages:**\n\n- **Custom Parsing Algorithm:** The project employs its own parsing algorithm,\n  written on Kotlin Multiplatform, specifically designed to handle complex\n  vector graphics that are not fully supported by the standard\n  `com.android.tools:sdk-common` library.\n- **Addresses Missing Features:** By addressing missing features in the default\n  SDK tools, the algorithm can parse and convert complex SVGs and AVGs that\n  other tools might fail to process correctly.\n- **Supports Complex Vectors:** Capable of handling intricate vector graphics,\n  ensuring that even detailed icons are accurately converted.\n- **Optimization via Trusted Tools**: The optimization of SVGs is performed\n  using external, well-known dependencies like **[SVGO](https://github.com/svg/svgo)** \n  and **[Avocado](https://github.com/alexjlockwood/avocado)**, ensuring \n  efficient and clean generated code without reinventing the wheel.\n\n## Platform Support\n\n### Command-line Tool\n\n| Platform           | Command-line Tool |\n|--------------------|:-----------------:|\n| macOS Arm64        |         ✅         |\n| macOS x64          |         ✅         |\n| Linux x64          |         ✅         |\n| Windows (mingwX64) |         ✅         |\n| Windows (WSL)      |         ✅         |\n\n### Gradle Plugin\n\n| Platform             | Gradle Plugin |\n|----------------------|:-------------:|\n| Android              |       ✅       |\n| Kotlin Multiplatform |       ✅       |\n\n## Available Tools\n\n### Command-line Tool\n\nA CLI tool for manually converting SVG or AVD files into Jetpack Compose\n`ImageVector` objects. It supports optimization of SVGs and provides various\noptions for customization.\n\nIdeal for CI integration as no additional dependencies are required (not even\nJava) other than the CLI tool's script and, if you wish, the optimization tools.\n\n[Full documentation for the Command-line Tool can be found here.](./svg-to-compose/README.md)\n\n### Gradle Plugin\n\nA Gradle plugin that automates the conversion process within your build system,\nideal for projects with a large number of icons or for ensuring consistency and\nsaving development time.\n\n[Full documentation for the Gradle Plugin can be found here.](./svg-to-compose-gradle-plugin/README.md)\n\n## Getting Started\n\n### Command-line Tool Installation\n\nThe CLI tool relies\non [Kotlin Native](https://kotlinlang.org/docs/native-overview.html) to parse\nthe SVG/AVD files. You can install it by:\n\n1. **Downloading the `s2c` script** from this repository and saving it in your\n   preferred folder, or\n2. **Cloning the project**.\n\nThe script will handle downloading or building the native binaries.\n\nAfter downloading the script or cloning the project:\n\n1. **Give execution permission** to the script:\n\n    ```console\n    chmod +xw s2c\n    ```\n\n2. **Optionally, add the script to your PATH** to run it from anywhere:\n\n    ```shell\n    export PATH=\u003cs2c path\u003e:$PATH\n    ```\n\n   Replace `\u003cs2c path\u003e` with the folder's path where you stored the script.\n\n#### External Dependencies\n\n\u003e [!NOTE]\n\u003e This is optional. If you don't want to use external dependencies, make sure to\n\u003e disable optimization via `--optimize false` when using the CLI tool or by\n\u003e calling the `optimize(enabled = false)` when using the Gradle Plugin.\n\n\u003e [!IMPORTANT]\n\u003e By default, Optimization is enabled by default on both CLI tool and Gradle\n\u003e Plugin.\n\nFor SVG optimization, this script relies on:\n\n- **[SVGO](https://github.com/svg/svgo)**: Optimizes SVG files by reducing paths.\n\n    ```console\n    npm -g install svgo\n    ```\n\n- **[Avocado](https://github.com/alexjlockwood/avocado)**: Optimizes Android\n  VectorDrawable and AnimatedVectorDrawable XML files.\n\n    ```console\n    npm -g install avocado\n    ```\n\n### Gradle Plugin Installation\n\nThe **SVG/XML to Compose** Gradle Plugin is available\non [Maven Central](https://search.maven.org/). It simplifies the process of\nconverting SVG and Android Vector Drawable (AVG/XML) files into Jetpack Compose\n`ImageVector` properties, automating the integration of vector assets into your\nCompose projects, ensuring a more efficient and error-free workflow.\n\n#### Applying the plugin\n\nAdd the plugin to your module's `build.gradle.kts` file:\n\n```kotlin\nplugins {\n    id(\"dev.tonholo.s2c\") version \"\u003clatest-version\u003e\"\n}\n```\n\nEnsure that Maven Central is included in your plugin repositories. If not, add\nthe following to your `settings.gradle.kts` or `build.gradle.kts`:\n\n```kotlin\npluginManagement {\n    repositories {\n        mavenCentral()\n        gradlePluginPortal()\n    }\n}\n```\n\n### Configuring .gitignore\n\nBoth the CLI tool and the Gradle plugin create a hidden folder to handle the\nconversion of the vectors without modifying the original file.\n\nTo avoid VCS noise, make sure you add the following to your `.gitignore` which\nis located in the root folder of your project or the folder you are using the\ntool in:\n\n```\n.s2c\n```\n\nThe algorithm will delete all the contents of the `.s2c` folder after parsing,\nbut leave it empty. If you delete the folder, it will be recreated on the next\nrun.\n\n## Usage\n\n### Using the Command-line Tool\n\n\u003e [!NOTE]\n\u003e For detailed usage instructions and options, please refer to\n\u003e the [Command-line Tool Documentation](./svg-to-compose/README.md).\n\nTo see all available options, run:\n\n```console\ns2c --help\n```\n\n**Example Commands**\n\n- **Convert an SVG to a Compose Icon:**\n\n    ```console\n    s2c -o OutputIconFile.kt \\\n        -p your.app.package.icon \\\n        -t your.app.package.theme.YourAppComposeTheme \\\n        input.svg\n    ```\n\n- **Convert an Android Vector Drawable to a Compose Icon:**\n\n    ```console\n    s2c -o OutputIconFile.kt \\\n        -p your.app.package.icon \\\n        -t your.app.package.theme.YourAppComposeTheme \\\n        input.xml\n    ```\n\n- **Convert all SVGs and AVGs within a directory to Compose Icons:**\n\n    ```console\n    s2c -o /my/desired/directory \\\n        -p your.app.package.icon \\\n        -t your.app.package.theme.YourAppComposeTheme \\\n        /my/svg/or/xml/directory\n    ```\n\n### Using the Gradle Plugin\n\n\u003e [!NOTE]\n\u003e For a complete list of configuration options and advanced usage, please refer\n\u003e to the [Gradle Plugin Documentation](./svg-to-compose-gradle-plugin/README.md).\n\nAfter applying the plugin, configure it in your `build.gradle.kts` file using\nthe `svgToCompose` extension. This extension allows you to specify how the\nSVG/AVG files should be processed and converted.\n\n**Basic Configuration Example**\n\n```kotlin\nsvgToCompose {\n    processor {\n        val projectIcons by creating {\n            from(layout.projectDirectory.dir(\"src/main/resources/icons\"))\n            destinationPackage(\"com.example.app.ui.icons\")\n            icons {\n                theme(\"com.example.app.ui.theme.AppTheme\")\n            }\n            // Additional configurations...\n        }\n    }\n}\n```\n\n## Result Examples\n\n### Simple SVG File\n\n#### Without Optimization\n\nCommand:\n\n```console\ns2c -o \u003capp path\u003e/app/src/main/java/dev/tonholo/composeicons/ui/icon/ShieldSolid.kt \\\n    -p dev.tonholo.composeicons.ui.icon \\\n    --theme dev.tonholo.composeicons.ui.theme.ComposeIconsTheme \\\n    -opt=false \\\n    \u003cparent-path\u003e/shield-halved-solid.svg\n```\n\nInput file: ![shield-halved-solid.svg](https://raw.githubusercontent.com/rafaeltonholo/svg-to-compose/refs/heads/main/samples/svg/shield-halved-solid.svg)\n\nOutput file: [ShieldSolid.nonoptimized.kt](https://raw.githubusercontent.com/rafaeltonholo/svg-to-compose/refs/heads/main/samples/ShieldSolid.svg.nonoptimized.kt)\n\n#### With Optimization\n\nCommand:\n\n```console\ns2c -o \u003capp path\u003e/app/src/main/java/dev/tonholo/composeicons/ui/icon/ShieldSolid.kt \\\n    -p dev.tonholo.composeicons.ui.icon \\\n    --theme dev.tonholo.composeicons.ui.theme.ComposeIconsTheme \\\n    -opt=true \\\n    \u003cparent-path\u003e/shield-halved-solid.svg\n```\n\nInput file: ![shield-halved-solid.svg](https://raw.githubusercontent.com/rafaeltonholo/svg-to-compose/refs/heads/main/samples/svg/shield-halved-solid.svg)\n\nOutput file: [ShieldSolid.svg.optimized.kt](https://raw.githubusercontent.com/rafaeltonholo/svg-to-compose/refs/heads/main/samples/ShieldSolid.svg.optimized.kt)\n\n### Complex SVG File\n\n#### Without Optimization\n\nCommand:\n\n```console\ns2c -o \u003capp path\u003e/app/src/main/java/dev/tonholo/composeicons/ui/icon/Illustration.kt \\\n    -p dev.tonholo.composeicons.ui.icon \\\n    --theme dev.tonholo.composeicons.ui.theme.ComposeIconsTheme \\\n    -opt=false \\\n    \u003cparent-path\u003e/illustration.svg\n```\n\nInput file: ![illustration.svg](https://raw.githubusercontent.com/rafaeltonholo/svg-to-compose/refs/heads/main/samples/svg/illustration.svg)\n\nOutput file: [Illustration.svg.nonoptimized.kt](https://raw.githubusercontent.com/rafaeltonholo/svg-to-compose/refs/heads/main/samples/Illustration.svg.nonoptimized.kt)\n\n#### With Optimization\n\nCommand:\n\n```console\ns2c -o \u003capp path\u003e/app/src/main/java/dev/tonholo/composeicons/ui/icon/Illustration.kt \\\n    -p dev.tonholo.composeicons.ui.icon \\\n    --theme dev.tonholo.composeicons.ui.theme.ComposeIconsTheme \\\n    -opt=true \\\n    \u003cparent-path\u003e/illustration.svg\n```\n\nInput file: ![illustration.svg](https://raw.githubusercontent.com/rafaeltonholo/svg-to-compose/refs/heads/main/samples/svg/illustration.svg)\n\nOutput file: [Illustration.svg.optimized.kt](https://raw.githubusercontent.com/rafaeltonholo/svg-to-compose/refs/heads/main/samples/Illustration.svg.optimized.kt)\n\n## Contributing \u0026 Community\n\nContributions are welcome! Please read the\n[CONTRIBUTING.md](./CONTRIBUTING.md) for setup instructions, coding standards,\nbranching and PR guidelines, and the PR checklist. By participating in this\nproject, you agree to abide by our\n[Code of Conduct](./CODE_OF_CONDUCT.md).\n\nHave an idea or found a bug? Open an issue:\nhttps://github.com/rafaeltonholo/svg-to-compose/issues/new/choose\n\n## License\n\nThis software is released under the terms of the [MIT License](https://github.com/rafaeltonholo/svg-to-compose/blob/main/LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frafaeltonholo%2Fsvg-to-compose","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frafaeltonholo%2Fsvg-to-compose","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frafaeltonholo%2Fsvg-to-compose/lists"}