Loading...
I created svgtosvelte to simplify SVG workflows by producing native Svelte 5 components with zero runtime dependencies, predictable outputs, and CI-friendly automation for seamless integration into Vite projects.
Pubish Date: 2026-04-28
Publish Time: 01:15:39
Update Date: 2026-05-08
When Svelte 5 finally reached its stable release, I found myself at a crossroads that many developers shared: I wanted to migrate my projects to leverage the power of Runes, but there was no active/native solution to manage SVGs icons for this new era. The tools I used to rely on (like svelvg) were anchored in Svelte 4 syntax, forcing me to choose between staying behind or cluttering my new codebase with legacy patterns like export let and $$restProps.
I didn’t want patches; I wanted a tool that spoke the language of Svelte 5 from day one, and seeing that void, I decided to build svgtosvelte.
One of the critical reasons I decided to launch this tool now is the evolution of Vite. Historically, using large icon collections was a developer’s nightmare. If you tried to import icons from a central file (a “barrel export”), Vite lags after importing more than 100 icons in development mode, causing extreme delays or even out-of-memory errors.

To avoid this, many of us resorted to “direct import hacks”—pointing to the exact path of the .svelte file—which made the code brittle and hard to maintain. However, “recent” optimizations in Vite have changed the game. Vite can now manage these dependencies much more intelligently during cold starts, eliminating those massive network waterfalls. svgtosvelte arrives at this exact technological milestone, allowing us to use clean barrel imports without sacrificing development speed.
In my pursuit of efficiency, the tool’s architecture had to evolve. My first version (V1) followed the traditional path: it processed the SVG by generating an Abstract Syntax Tree (AST) to transform it. While robust, it was computationally expensive.

For Version 2 (V2), I decided to rewrite everything from scratch, stripping away all heavy compilation dependencies. Instead of parsing an AST, svgtosvelte now works directly on the SVG string using highly optimized regex and string manipulation. The results validated this approach:
| Metrics | V1 (AST) | V2 (String-based) |
| Time per icon | ~2.9 ms | ~0.49 ms |
| Deps | 2+ Heavy | 0 (Zero-deps) |
| Approach | Parse → Walk → Build | Regex/String manipulation |
When working with systems containing thousands of icons—such as the FluentUI set—manual conversion is simply not an option. I needed a CLI that could mass-inject attributes like fill="currentColor", generate TypeScript definitions automatically, and ensure every component was perfectly responsive. Every second counts in a GitHub Action.
Ultimately, this project was born from a personal need for consistency and performance. It’s not just about converting files; it’s about providing the infrastructure so any developer can focus on building incredible interfaces in Svelte 5, knowing their graphical assets are as modern and efficient as the rest of their application.
svgtosvelte was built to solve a practical problem: convert SVG icons into native Svelte 5 components with speed, simplicity, and no runtime baggage. By moving from an AST-heavy approach to a lean string/regex pipeline, it delivers substantial build-time performance gains, zero runtime dependencies, and CI-friendly automation (CLI, TypeScript defs, and automatic attributes). For teams modernizing Svelte projects, it removes friction around icon handling and scales cleanly across large icon sets. If you want predictable, fast SVG-to-component conversion that fits into modern Vite workflows, svgtosvelte is a pragmatic, performance-first choice.