{"id":48527752,"url":"https://github.com/madebyfrmwrk/svgm","last_synced_at":"2026-04-12T03:00:37.588Z","repository":{"id":349345644,"uuid":"1201930472","full_name":"madebyfrmwrk/svgm","owner":"madebyfrmwrk","description":"Fast, native SVG optimization in Rust, with fixed-point convergence, safe defaults, and a modern CLI.","archived":false,"fork":false,"pushed_at":"2026-04-07T21:20:50.000Z","size":253,"stargazers_count":2,"open_issues_count":5,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-04-07T23:25:52.501Z","etag":null,"topics":["cli","minification","optimization","rust","svg","svg-minifier","svg-optimizer","svgm","vector-graphics","xml"],"latest_commit_sha":null,"homepage":"https://svgm.dev","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/madebyfrmwrk.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE-APACHE","code_of_conduct":null,"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":"2026-04-05T11:07:06.000Z","updated_at":"2026-04-07T21:20:55.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/madebyfrmwrk/svgm","commit_stats":null,"previous_names":["builtbyfrmwrk/svgm"],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/madebyfrmwrk/svgm","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/madebyfrmwrk%2Fsvgm","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/madebyfrmwrk%2Fsvgm/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/madebyfrmwrk%2Fsvgm/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/madebyfrmwrk%2Fsvgm/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/madebyfrmwrk","download_url":"https://codeload.github.com/madebyfrmwrk/svgm/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/madebyfrmwrk%2Fsvgm/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31579058,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-08T14:31:17.711Z","status":"ssl_error","status_checked_at":"2026-04-08T14:31:17.202Z","response_time":54,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5: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":["cli","minification","optimization","rust","svg","svg-minifier","svg-optimizer","svgm","vector-graphics","xml"],"created_at":"2026-04-07T23:01:51.318Z","updated_at":"2026-04-09T00:01:14.712Z","avatar_url":"https://github.com/madebyfrmwrk.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n  \u003cbr\u003e\n  \u003ca href=\"https://github.com/madebyfrmwrk/svgm\"\u003e\n    \u003cpicture\u003e\n      \u003csource media=\"(prefers-color-scheme: dark)\" srcset=\"https://raw.githubusercontent.com/madebyfrmwrk/svgm/main/assets/svgm-dark.svg\"\u003e\n      \u003csource media=\"(prefers-color-scheme: light)\" srcset=\"https://raw.githubusercontent.com/madebyfrmwrk/svgm/main/assets/svgm-light.svg\"\u003e\n      \u003cimg alt=\"svgm\" src=\"https://raw.githubusercontent.com/madebyfrmwrk/svgm/main/assets/svgm-light.svg\" height=\"42\"\u003e\n    \u003c/picture\u003e\n  \u003c/a\u003e\n  \u003cbr\u003e\n  \u003cbr\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n  SVG optimization, rewritten in Rust.\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"#install\"\u003eInstall\u003c/a\u003e \u0026middot;\n  \u003ca href=\"#usage\"\u003eUsage\u003c/a\u003e \u0026middot;\n  \u003ca href=\"#benchmarks\"\u003eBenchmarks\u003c/a\u003e \u0026middot;\n  \u003ca href=\"#how-it-works\"\u003eHow it works\u003c/a\u003e \u0026middot;\n  \u003ca href=\"#contributing\"\u003eContributing\u003c/a\u003e\n\u003c/p\u003e\n\n\u003cdiv align=\"center\"\u003e\n\n[![MIT licensed][license-badge]][license-url]\n[![Crate][crates-badge]][crates-url]\n[![Build Status][ci-badge]][ci-url]\n\n\u003c/div\u003e\n\n---\n\n## About\n\nSVG files exported from tools like Figma, Illustrator, and Inkscape often include metadata, redundant attributes, unnecessary wrapper structure, and verbose path data.\n\n[SVGO](https://github.com/svg/svgo) has been the standard SVG optimizer for years. SVGM takes a different approach: a native Rust optimizer designed around fixed-point convergence, safe defaults, and a modern CLI. Like [oxlint](https://oxc.rs) for ESLint, SVGM targets the same problem with a different architecture.\n\n### Fixed-point convergence\n\nIn some optimizers, additional runs can still reduce output further because later passes create opportunities for earlier ones. SVGM is designed to converge in a single invocation by running optimization passes over the in-memory AST until the document stabilizes.\n\n```\n$ svgm icon.svg\n\n  icon.svg\n  13.5 KiB -\u003e 6.6 KiB (51.1% smaller)  0ms  3 passes\n```\n\nNo re-parsing between iterations. No manual multipass flag. One invocation, fixed-point optimization.\n\n## Install\n\n### From source (requires [Rust](https://rustup.rs))\n\n```bash\ncargo install svgm\n```\n\n### Build from repo\n\n```bash\ngit clone https://github.com/madebyfrmwrk/svgm.git\ncd svgm\ncargo build --release\n# Binary at ./target/release/svgm\n```\n\n## Usage\n\n```bash\nsvgm icon.svg                    # Optimize in place (overwrites the file)\nsvgm icon.svg -o icon.min.svg    # Write to a different file\nsvgm icon.svg --stdout           # Print to stdout instead of overwriting\nsvgm icon.svg --dry-run          # Preview size reduction without writing\nsvgm icons/*.svg                 # Optimize multiple files in place\nsvgm -r ./icons                  # Recursively optimize all SVGs in a directory\nsvgm -r ./icons -o ./icons-min   # Recursive with output directory\nsvgm icon.svg --quiet            # Suppress all output except errors\n```\n\nWhen piped (e.g. `svgm icon.svg | gzip`), output goes to stdout automatically.\n\n### Presets\n\n```bash\nsvgm icon.svg --preset safe         # Removal + normalization only (17 passes)\nsvgm icon.svg --preset balanced     # Full pass set (24 passes, default)\nsvgm icon.svg --preset aggressive   # Full pass set, lower precision\nsvgm icon.svg --precision 2         # Override numeric precision on any preset\n```\n\n### Config file\n\nCreate an `svgm.config.toml` in your project root:\n\n```toml\npreset = \"balanced\"\nprecision = 3\n\n[passes]\nremoveDesc = true          # opt-in: strip \u003cdesc\u003e and \u003ctitle\u003e\nconvertShapeToPath = false  # opt-out: disable a specific pass\n```\n\nSVGM auto-discovers the config by walking up from the input file's directory. Use `--config path` to specify explicitly, or `--no-config` to skip. See [`svgm.config.example.toml`](svgm.config.example.toml) for a starter template.\n\n## Benchmarks\n\n100 real-world SVG logos (Figma, Illustrator, Inkscape, svgrepo exports). 902.7 KiB total original size.\n\n| | **SVGM** | **SVGO** |\n|:--|:--|:--|\n| **Compression** | 14.9% | 18.2% |\n| **Median time** | 110ms | 291ms |\n| **Speed** | **2.6x faster** | baseline |\n| **Invocations to converge** | **1** | 1-3 |\n\nFull benchmark details at [svgm.dev/docs/benchmarks](https://svgm.dev/docs/benchmarks).\n\nSVGM ships as a single native binary. The ~3 point compression gap is actively being closed.\n\n## How it works\n\n### Architecture\n\n```\n              parse              optimize              serialize\nSVG string ---------\u003e AST tree ---------\u003e AST tree -----------\u003e SVG string\n             xmlparser         fixed-point            minified\n                                  loop                 output\n```\n\n1. **Parse** — `xmlparser` tokenizes the SVG into an arena-based AST with parent pointers\n2. **Optimize** — Run all passes in a loop until no pass reports a change (max 10 iterations)\n3. **Serialize** — Write the AST back as a minified SVG string\n\nPasses operate directly on the in-memory AST, avoiding repeated serialize/parse cycles between iterations.\n\n### Optimization passes\n\n**Removal** — strip dead weight\n- Comments, doctypes, XML processing instructions\n- Editor metadata (Inkscape, Illustrator, Sketch, Figma)\n- Empty containers, empty attributes, empty text elements\n- Unused namespace declarations\n- Attributes matching SVG spec defaults (`opacity=\"1\"`, `stroke=\"none\"`, etc.)\n\n**Normalization** — tighten values\n- Collapse whitespace in attributes\n- Round numeric values, strip trailing zeros and default `px` units\n- Shorten colors: `rgb(255,0,0)` -\u003e `red`, `#aabbcc` -\u003e `#abc`\n\n**Structural** — simplify the tree\n- Collapse useless `\u003cg\u003e` wrappers (no-attribute groups, single-child groups)\n- Reference safety: groups with `clip-path`, `mask`, or `filter` are never collapsed\n\n**Transform** — simplify and apply transforms\n- Merge consecutive transforms into a single equivalent (`translate(10,20) translate(5,5)` -\u003e `translate(15,25)`)\n- Remove identity transforms (`scale(1)`, `translate(0,0)`, `rotate(0)`)\n- Apply pure translates directly to element coordinates and path data\n- Push transforms from single-child groups to child, enabling group collapse\n\n**Geometry** — compress path data\n- Shape-to-path conversion (rect, circle, ellipse, line, polyline, polygon → shorter `\u003cpath\u003e`)\n- Path merging (adjacent non-overlapping paths with identical attributes, with geometric intersection safety)\n- Absolute-to-relative coordinate conversion where shorter\n- `L` to `H`/`V` shortcut commands\n- `C` to `S` and `Q` to `T` shorthand curves (reflected control points)\n- Degenerate curve to line simplification (collinear control points)\n- Redundant command removal (zero-length lines)\n- Strip leading zeros (`.5` instead of `0.5`)\n- Implicit command repetition\n- Minimal separator insertion\n\n**IDs** — clean up references\n- Remove unused `id` attributes\n- Shorten referenced IDs to minimal unique names\n\n### Safety\n\nSVGM is conservative by default:\n\n- `\u003cdesc\u003e` and `\u003ctitle\u003e` are **preserved** (accessibility semantics)\n- `\u003csymbol\u003e` and `\u003cdefs\u003e` with `id` attributes are **never removed** (may be referenced)\n- Animation elements (`\u003canimate\u003e`, `\u003canimateTransform\u003e`, etc.) are **fully preserved**\n- `\u003cforeignObject\u003e` content is **never touched**\n- `fill=\"black\"` on `\u003csvg\u003e` is **kept** (inherited by children)\n\n## Rust API\n\n```rust\nuse svgm_core::optimize;\n\nlet result = optimize(\"\u003csvg\u003e...\u003c/svg\u003e\").unwrap();\nprintln!(\"{}\", result.data);       // optimized SVG string\nprintln!(\"{}\", result.iterations); // convergence iterations\n```\n\nWith preset/precision control:\n\n```rust\nuse svgm_core::{optimize_with_config, Config, Preset};\n\nlet config = Config {\n    preset: Preset::Safe,\n    precision: Some(2),\n    ..Config::default()\n};\nlet result = optimize_with_config(\"\u003csvg\u003e...\u003c/svg\u003e\", \u0026config).unwrap();\n```\n\n## Project structure\n\n```\nsvgm/\n├── crates/\n│   ├── svgm-core/       # Parser, AST, optimizer, serializer, passes\n│   └── svgm-cli/        # CLI binary (clap + indicatif)\n├── LICENSE-MIT\n└── LICENSE-APACHE\n```\n\n## Roadmap\n\n- [x] Transform merging, application, and push-down (all 3 phases)\n- [x] Shape-to-path conversion (rect, circle, ellipse → shorter `\u003cpath\u003e`)\n- [x] Path merging (adjacent paths with identical attributes)\n- [x] ID cleanup (remove unused, shorten used)\n- [x] CSS `\u003cstyle\u003e` inlining and minification\n- [x] Recursive directory processing (`-r`)\n- [x] Safety presets and config file support\n- [x] WASM build for browser usage\n- [ ] Node.js bindings via napi-rs\n\n## Contributing\n\nSVGM is early, but already usable. Contributions and real-world SVG edge cases are especially helpful.\n\n```bash\ngit clone https://github.com/madebyfrmwrk/svgm.git\ncd svgm\ncargo test --workspace\ncargo clippy --workspace  # must pass clean\n```\n\nIf you find an SVG that SVGM corrupts or handles worse than expected, please [open an issue](https://github.com/madebyfrmwrk/svgm/issues) with the SVG attached.\n\n## License\n\nDual-licensed under [MIT](LICENSE-MIT) and [Apache 2.0](LICENSE-APACHE).\n\n[license-badge]: https://img.shields.io/badge/license-MIT%2FApache--2.0-blue.svg\n[license-url]: https://github.com/madebyfrmwrk/svgm/blob/main/LICENSE-MIT\n[crates-badge]: https://img.shields.io/crates/v/svgm.svg\n[crates-url]: https://crates.io/crates/svgm\n[ci-badge]: https://github.com/madebyfrmwrk/svgm/actions/workflows/ci.yml/badge.svg\n[ci-url]: https://github.com/madebyfrmwrk/svgm/actions\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmadebyfrmwrk%2Fsvgm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmadebyfrmwrk%2Fsvgm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmadebyfrmwrk%2Fsvgm/lists"}