Skip to content
Jellykit

SVG Sprite Builder

Combine SVG icons into one sprite of <symbol> elements, with tidy IDs and a ready <use> snippet for every icon.

  • Runs on your device
  • Works in the background
Loading tool

About SVG Sprite Builder

An SVG sprite puts a whole icon set in one file or one block of markup, and each icon is then drawn with a short <use> tag. Drop in your SVG files and this tool turns each one into a <symbol> named after its file, keeps its viewBox and its stroke and fill settings, and gives you the snippet to place it.

IDs inside the icons, such as gradients and clip paths, get the icon name in front so two icons can never clash. You can also tidy each icon with svgo first, and switch the colors to currentColor so the icons follow the text color around them.

How it works

  1. Each file is read as text in your browser. Its root <svg> becomes a <symbol>: the viewBox is kept (or worked out from width and height), presentation attributes such as fill and stroke-width are kept, and sizes and namespaces are dropped.
  2. svgo parses every icon, so broken files are reported by line and column. It removes scripts and event handlers, prefixes the icon own IDs and references with its symbol ID, and, if you ask, optimizes the markup.
  3. Symbol IDs come from the file names, lower-cased with accents and spaces removed, after your prefix. A name that is already taken is numbered.
  4. The sprite is a hidden <svg> holding every symbol. Put it at the start of the page body, or save it as a file and point the snippets at it.

Questions

How do I size and color the icons?

Style the outer <svg> of each snippet, for example .icon { width: 1.5em; height: 1.5em; }. With Recolor with currentColor on, the icons take the CSS color of their surroundings, so color: red on a button turns its icon red.

Should the sprite go in the page or in a file?

In the page, the icons appear with no extra request. In a file, browsers cache it across pages, but it must be served from the same site, because <use> does not load symbols from other origins.

Why did a file get left out?

It was not an SVG, or its markup is broken. The note says which, and for broken markup gives the line and column where reading stopped. The other icons still go into the sprite.

How many icons can I add?

Up to 300 files, each up to 2 MB and 20 MB in all. Icons are usually a few kilobytes, so this covers large sets.

Everything you enter here is processed in this browser tab. Nothing is uploaded, logged or shared. How privacy works here.