Export an SVG from Figma, Illustrator, or Sketch and open it in a text editor. You'll often find hundreds of lines where dozens should do — namespace declarations for software that no longer exists, layer metadata, editor-specific attributes, unnecessary decimal precision on path coordinates. A 40KB SVG icon can frequently be reduced to 8KB without any visible change to how it renders.
The DevToolShack SVG Optimizer removes all of this bloat instantly in your browser — paste your SVG, copy the optimized output, done. Nothing uploaded to a server.
What's Inside a Bloated SVG
Here's what a typical Illustrator or Figma export contains that you almost certainly don't need:
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generator: Adobe Illustrator 27.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<svg xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
id="Layer_1"
x="0px" y="0px"
viewBox="0 0 24 24"
style="enable-background:new 0 0 24 24;"
xml:space="preserve">
<metadata>
<rdf:RDF>
<cc:Work rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type rdf:resource="http://purl.org/dc/dcmitype/StillImage"/>
</cc:Work>
</rdf:RDF>
</metadata>
<path d="M11.99999237060547,2.0000076293945312 L..." />
</svg>
After optimization, the same icon might look like:
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<path d="M12 2L..."/>
</svg>
What Gets Removed (Safely)
- XML declaration —
<?xml version="1.0"?>is unnecessary when SVG is embedded in HTML - Comments — generator comments, copyright comments (check this matters for your SVGs)
- Metadata elements — RDF, Dublin Core, creator info — browsers ignore all of this
- Unused namespace declarations —
xmlns:xlink,xmlns:dc, etc., when not referenced - Editor-specific attributes —
id="Layer_1",xml:space,style="enable-background:..." - Default attribute values — attributes that match the SVG default don't need to be stated
- Unnecessary precision —
11.99999237060547becomes12 - Empty groups and elements —
<g></g>adds nothing - Whitespace — indentation and newlines in the output
What NOT to Remove
- IDs used by CSS or JavaScript — if your code references
#icon-arrow, the ID must stay - Accessibility attributes —
role,aria-label,titleelements improve screen reader support - Animation elements —
<animate>,<animateTransform>, CSS animation targets - Clip paths and masks — complex effects that reference other elements
- Significant decimal precision — very detailed paths may need more than 1 decimal place
Typical Size Savings
| SVG Type | Typical Reduction |
|---|---|
| Simple icon from Figma | 40–70% |
| Illustration from Illustrator | 30–60% |
| Icon set (multiple icons) | 40–65% |
| Complex illustration with gradients | 20–40% |
| Hand-coded SVG (already clean) | 5–15% |
Inline SVG vs External File
How you use the SVG in HTML also affects performance:
- Inline SVG — embedded directly in HTML. No extra HTTP request, CSS can target elements, JavaScript can manipulate it. Increases HTML size, not cacheable separately.
- External file (
<img src="icon.svg">) — cacheable, smaller HTML, but CSS and JS can't reach inside the SVG. - CSS background-image — purely decorative, no accessibility, no interactivity.
- SVG sprite — one external SVG file containing multiple
<symbol>definitions, referenced with<use href="#id">. Best of both worlds for icon sets.
Optimizing SVGs in a Build Pipeline
For automated optimization as part of your build process:
# SVGO — the standard SVG optimizer
npm install -g svgo
# Optimize a single file
svgo icon.svg -o icon.optimized.svg
# Optimize all SVGs in a directory
svgo --folder ./assets/icons --output ./assets/icons/optimized