Why Your SVGs Are Too Big — How to Optimize SVG File Size
An SVG exported from Figma or Illustrator carries metadata, editor cruft, and precision you do not need. Here is what to strip, what to keep, and how much smaller the file gets.
SVG is the only image format that scales perfectly to any screen size. It is also the only image format where the file you export from your design tool is routinely two to five times larger than it needs to be.
This is not because SVG is inefficient. It is because design tools optimize for editability, not for delivery. An SVG destined for a web page has different requirements than one destined for a round trip back into Illustrator.
What makes SVGs unnecessarily large
Editor metadata
Every design tool stamps its mark on the file. Illustrator adds xmlns:sodipodi, xmlns:inkscape, processing instructions, and <metadata> blocks that identify the tool, version, and author. Figma adds its own namespace attributes. Sketch does the same.
None of this metadata is rendered by a browser. It exists so the design tool can reopen the file and preserve its layer structure. If the SVG is going to a web page, it is dead weight.
Excessive decimal precision
When a design tool exports coordinates, it uses the precision of its internal rendering engine. You will see paths like:
<path d="M 12.345678901234 67.890123456789 L 98.765432109876 43.210987654321"/>
A browser renders pixels. On a standard display, any precision beyond two decimal places is invisible. On a retina display, you might benefit from three. Twelve decimal places is twelve minus three equals nine digits of waste, per coordinate, across every path in the file.
On a complex illustration with thousands of coordinates, trimming precision from 12 digits to 2 can reduce file size by 15-25% by itself.
Redundant attributes
Design tools export every attribute explicitly, even when the value matches the SVG default. For example:
<rect fill-opacity="1" stroke-opacity="1" opacity="1"/>
All three default to 1 in the SVG spec. Declaring them adds bytes and changes nothing.
Similarly, fill="black" can be omitted when the parent <svg> already sets fill="black", because SVG attributes cascade through the DOM.
Empty groups and unused definitions
Illustrator often wraps elements in <g> groups that carry no attributes — they exist for the layer panel but serve no rendering purpose. Sketch and Figma can leave behind unused <defs> blocks: gradient definitions, clip paths, or filter elements that were part of an earlier design state and are no longer referenced by anything in the file.
Comments and whitespace
Design tool exports include XML comments, sometimes with version strings or license boilerplate. Whitespace — indentation, line breaks, trailing spaces — is ignored by the renderer but adds to file size. On a well-structured SVG, whitespace alone can account for 5-10% of the file.
What to remove (and what to keep)
Always safe to remove
- Editor metadata (
<metadata>, tool-specific namespace declarations) - XML comments
- Redundant whitespace and indentation
- Unused
<defs>entries (gradients, clip paths, filters not referenced by any element) - Empty
<g>groups (groups with no attributes and no meaningful grouping purpose) - Default attribute values (
fill-opacity="1",stroke-opacity="1") - Excess decimal precision (anything beyond 2-3 decimal places)
<?xml?>processing instructions (not needed when SVG is inline or served asimage/svg+xml)<!DOCTYPE>declarations (not needed for SVG 1.1 in modern browsers)- IDs that are not referenced by
<use>, CSS, or JavaScript
Keep these
viewBox— this is what makes your SVG scale. Never remove it.xmlns="http://www.w3.org/2000/svg"— required when the SVG is served as a standalone file.- IDs that are referenced by CSS, JavaScript, or
<use>elements. aria-*attributes and<title>/<desc>elements if they provide accessibility.- Gradients, filters, and clip paths that are actually used.
preserveAspectRatioif your SVG should not stretch to fill its container.
How minification works
SVG minification is the process of removing the unnecessary parts listed above. A minifier parses the SVG XML, identifies what is renderable and what is not, and outputs a cleaned version.
The most widely used SVG optimization tool is SVGO (SVG Optimizer), an open-source Node.js library. It runs a configurable set of plugins — each one targeting a specific optimization: remove comments, collapse groups, trim precision, remove unused defs, merge paths, and so on.
If you do not want to install Node.js or configure SVGO’s plugin pipeline, online tools do the same job. ToolsVale’s SVG Minifier runs in your browser — the file never leaves your machine — and applies the standard SVGO optimizations with sensible defaults.
What kind of reduction to expect
The reduction depends on the source. Here are typical ranges:
| Source | Typical reduction | Why |
|---|---|---|
| Illustrator export | 30-60% | Heavy metadata, namespace declarations, full precision |
| Figma export | 20-40% | Cleaner than Illustrator, but still carries excess precision and empty groups |
| Sketch export | 25-45% | Similar to Figma, with additional Sketch-specific attributes |
| Hand-coded SVG | 5-15% | Mostly whitespace and minor precision trimming |
| SVG from an icon library | 10-20% | Usually pre-optimized, but whitespace and comments remain |
A logo SVG that exports from Illustrator at 12 KB will typically compress to 4-6 KB after minification. An icon set of 40 SVGs that totals 200 KB can drop to 80-100 KB.
When SVG minification matters most
Performance-critical pages
Your landing page loads three SVG illustrations, a logo, and twelve icons. That is 16 SVG files. If each is 10 KB over-size because of editor metadata, you are adding 160 KB of unnecessary payload. On a 3G connection, that is a noticeable delay. On a page that Google is measuring for Core Web Vitals, it contributes to Largest Contentful Paint.
Icon systems
If you are using an SVG sprite sheet or inline SVG icons across your site, every icon carries its own metadata on every page load. A 40-icon sprite at 200 KB could be 80 KB — a 120 KB saving that applies to every page that loads the sprite.
Animated SVGs
SVG animations (CSS or SMIL) add complexity. The larger the SVG DOM, the more work the browser does on each animation frame. Removing unnecessary elements does not just reduce file size — it reduces the number of DOM nodes the browser has to repaint.
Email templates
Many email clients support inline SVG. Email HTML has strict size limits (some clients clip messages over 102 KB). Every byte in your SVG competes with your actual content for that budget.
Beyond minification: structural optimizations
Minification removes waste. Structural optimization changes how the SVG is built, which can produce larger reductions but requires more care.
Path merging
Two overlapping paths with the same fill and stroke can sometimes be merged into a single <path> element. This reduces DOM complexity and file size. However, it changes the SVG structure — if you later need to animate or style those paths independently, the merge is irreversible.
SVGO has a mergePaths plugin that handles common cases. It is conservative by default and will not merge paths that would change the visual output.
Shape to path conversion
A <rect>, <circle>, or <ellipse> element can be converted to a <path> element. This sometimes saves bytes (the path representation is shorter) and sometimes costs bytes (the shape element is shorter). SVGO’s convertShapeToPath plugin makes this decision per element.
Gzip and Brotli
After minifying the SVG itself, make sure your server compresses it during transfer. SVG is text-based XML, and text compresses extremely well. A 6 KB minified SVG will typically transfer as 1.5-2 KB with gzip or 1-1.5 KB with Brotli.
Check your server’s Content-Encoding header. If it is not gzip or br when you load an SVG, you are transferring uncompressed text.
A practical workflow
- Export from your design tool as you normally would.
- Run the SVG through a minifier. If you want it done in your browser with no install, use ToolsVale’s SVG Minifier. If you want it in your build pipeline, use SVGO via CLI or as a webpack/vite plugin.
- Check the output visually. Open the minified SVG in a browser and compare it to the original. They should look identical. If they do not, the minifier removed something it should not have — review the optimization settings.
- Verify the file size. The minified version should be meaningfully smaller. If it is not, the source was already well-optimized (common with icon libraries).
- Deploy the minified version. Use the minified SVG on your site. Keep the original in your design files for future editing.
Tools referenced in this guide
- SVG Minifier — Minify SVGs in your browser, no upload. Applies SVGO optimizations with sensible defaults.
- Compress Image — For raster images (PNG, JPG, WebP), batch compress with quality control.