Skip to content

SVG Optimizer

Caution

Optimize SVG files for web use by removing redundant markup, applying SVGO transforms, converting to symbol sprites, and generating accessible inline SVGs.

By community 1,900 v1.0.0 Updated 2026-03-08

Install

Claude Code

Copy the SKILL.md file to .claude/skills/svg-optimizer.md

About This Skill

SVG Optimizer analyzes SVG files and applies a comprehensive optimization pipeline to reduce file size while preserving visual fidelity and adding proper accessibility attributes.

Optimization Passes

  1. Metadata removal — Strips editor-specific attributes (Figma node IDs, Sketch layer names, Adobe Illustrator namespaces)
  2. Path simplification — Merges redundant path segments, removes invisible elements (zero-opacity, zero-width)
  3. Attribute cleanup — Removes default attribute values, converts RGB colors to hex shorthand, normalizes viewBox
  4. Transform consolidation — Merges nested transform matrices into a single matrix operation
  5. Number precision — Reduces coordinate decimal places to 2-3 significant digits

Symbol Sprite Generation

Combines multiple SVG files into a single `<svg>` with `<symbol id="icon-name">` elements. Usage via `<use href="#icon-name">`. Generates TypeScript type unions for available icon names.

Accessibility

Adds `role="img"`, `aria-label`, `<title>`, and `<desc>` elements. For decorative icons, adds `aria-hidden="true"` and `focusable="false"`.

Output Formats

  • Optimized standalone `.svg` files
  • `sprite.svg` symbol sprite
  • React `<Icon>` component wrapper with TypeScript props
  • CSS mask-image icon utility classes

Use Cases

  • Batch optimizing exported Figma SVGs before committing to the codebase
  • Converting a folder of individual SVG icons into a single symbol sprite
  • Adding title and desc elements for screen reader accessibility
  • Removing Figma-specific metadata and inline styles from exported SVGs

Pros & Cons

Pros

  • + Typically reduces SVG file size by 40-70% without visual quality loss
  • + Symbol sprite reduces HTTP requests for icon-heavy pages
  • + Accessibility attributes added automatically for compliance
  • + TypeScript icon name union prevents typos in component usage

Cons

  • - Aggressive path simplification can alter hairline stroke visuals at small sizes
  • - Symbol sprite requires same-origin or CORS headers for cross-domain use

Related AI Tools

Related Skills

Stay Updated on Agent Skills

Get weekly curated skills + safety alerts

每周精选 Skills + 安全预警