Description
svg2sprite is a small Node.js module that combines separate SVG icons into one SVG sprite. You create a collection, add each icon by name, and compile the collection into a single sprite that a web page can reference. The module provides methods to add, get and remove items, to clear the collection and to compile the finished sprite. Options control the attributes on the root svg tag, and an inline mode that prevents SVG namespace declarations so the sprite can be embedded directly in HTML. You can also set attributes and a name prefix or suffix for each icon. Cleanup options strip empty tags, remove title and desc tags by default, and remove any attributes you list. Individual settings can be passed when adding an item. The README says the module was written because existing solutions have many dependencies, and it aims to stay simple. The README shows the install step. It suits developers who build icon sprites as part of a build process and want a minimal tool for it.…
Highlights
- Combines SVG icons into one sprite
- Add, get, remove and clear icons
- Inline mode for embedding in HTML
- Prefix and suffix icon names
- Strips empty tags and unwanted attributes
Ratings & Reviews
No ratings yet
Be the first to rate svg2sprite.
People also visit
svg2sprite FAQ
What does svg2sprite do?
It builds a single SVG sprite from separate SVG icons, so a page can load one file that holds all of its icons.
How do I use it?
Create a collection, add each icon by name, then call compile to get the finished sprite. The README has code examples.
Can I embed the sprite directly in HTML?
Yes. The inline option prevents SVG namespace declarations and sets attributes so the sprite can be hidden inside the page.
Why was it written?
The README says existing solutions have many dependencies, and svg2sprite was written as a simpler alternative.
Can I clean up the icons?
Yes. Options strip empty tags, remove title and desc tags by default, and remove any attributes you list.
What are the best svg2sprite alternatives?
Popular alternatives to svg2sprite include svg-sprite, vue-svgicon and astro-iconset. See all svg2sprite alternatives














