b2KIT

SVG Sprite Builder

Combine multiple SVG icons into a single sprite file with symbol IDs for efficient web usage.

Tested tool guide Tested browser tools Checked August 16, 2026

What SVG Sprite Builder does, with a checked example

Every icon on a page costs a request, and twenty icons cost twenty round trips. This tool collapses that: you paste or upload the SVG files for your icons and it returns one sprite - a single SVG document whose icons live in <symbol> elements, each addressable by id. The combining happens entirely in the browser; your icons never leave the machine. The page loads the sprite once, and every icon is a <use> away. The surprise is on the other end: a sprite file referenced across origins, or straight off your hard drive, renders blank, because <use> cannot reach outside the page's own origin. Inline the sprite instead.

Worked example

A concrete input and expected output from the current implementation.

Input

Two SVG files:

triangle.svg
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M12 2l10 18H2z"/></svg>

circle.svg
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><circle cx="12" cy="12" r="8"/></svg>

Expected output

<svg xmlns="http://www.w3.org/2000/svg">
  <symbol id="triangle" viewBox="0 0 24 24">
    <path d="M12 2l10 18H2z"/>
  </symbol>
  <symbol id="circle" viewBox="0 0 24 24">
    <circle cx="12" cy="12" r="8"/>
  </symbol>
</svg>

Each input file becomes one <symbol>: the id follows the source file name, the usual convention for sprite builders, and the viewBox is lifted onto the symbol so the icon scales to the size of the element that references it. The page then shows an icon with <svg><use href="#triangle"/></svg>.

How the result is produced

1

Parsing icons into symbols

Each source SVG is parsed and reduced to its drawing: the viewBox moves onto a new <symbol> element, and the inner paths, shapes, and groups are copied in unchanged. A unique id is assigned to each symbol, usually from the source file's name. The symbols are then concatenated inside one <svg> root with the SVG namespace, so the result is a single valid, standalone file.

2

Referencing the sprite

On the page, the sprite document is embedded once - inlined into the HTML or loaded as a same-origin file - and hidden, since its symbols are not meant to be seen directly. An icon is placed wherever needed with <svg><use href="#id"/></svg>. The symbol's viewBox scales the drawing to the element's size, and fills written as currentColor inherit from the surrounding page, so one sprite serves every color variant.

Good uses

  • A marketing or template site with dozens of icons: replace many icon file requests with one sprite the browser caches, and place each icon with a <use> tag.
  • Keeping a shared icon set consistent across pages or components: regenerate the sprite from the source icons and every page that references the symbols picks up the change.
  • Dropping an icon font: SVG symbols stay sharp at every size and screen density and give CSS control of color, instead of a font download with its own styling rules.

Limits and checks

  • Two source icons that end up with the same id - typically the same file name arriving from different folders - collide: only one of the symbols is reachable by that id, so references resolve ambiguously and one icon effectively disappears.
  • An icon whose source has no viewBox (fixed width and height attributes instead) produces a symbol that cannot scale to the element referencing it, so the icon renders at an unintended size.
  • Blank icons after integrating the sprite usually mean the sprite is being referenced across origins or from file://, not that the sprite file is broken - <use> cannot pull symbols from another origin, so inline the sprite into the page.

Common questions

Why are my icons blank when I open the page directly from disk?

Almost always the same-origin rule for <use>. A sprite loaded as an external file must come from the page's own origin; a page opened from disk has no origin to match, and browsers treat the reference as cross-origin, so every <use> resolves to nothing. Inline the sprite into the HTML, or serve the page and sprite from the same domain, and the icons appear.

Can I recolor a sprite icon with CSS, or is its color fixed?

Usually yes, with one condition. If the icon's drawing uses fill="currentColor" or no fill at all, CSS on the referencing element - color, fill, or a class - recolors it, which is how one sprite serves hover states and themes. A hardcoded fill attribute still loses to your CSS; only an inline style="fill:..." inside the icon wins permanently, so strip those from source files before building the sprite.

References and verification

The example and behavioral notes were checked against the browser implementation. Standards and primary references below define the relevant format, formula, or platform behavior.

Related Tools