Skip to content
ToolShedby Wasim Shaikh

SVG Optimizer

Compress SVG files with SVGO 4 in your browser. Before/after size, gzip size and preview, plus batch optimize up to 200 files to a .zip.

Lower is smaller. 1–2 suits 24px icons; keep 3 or more for large, detailed art.

Optimize many files at once

Up to 200 SVGs with the settings above, downloaded as one .zip.

How to Optimize an SVG

  1. Add an SVG. Paste the code, drop an .svg file on the box or upload one. For a folder of icons, use "Choose SVG files" to optimize up to 200 at once.
  2. Tune the settings. Lower the number precision for small icons, and turn on options such as currentColor or Remove width/height when you need them.
  3. Compare. Check the before and after preview, the byte saving and the gzipped size.
  4. Download. Copy the code, download the .svg, copy it as a CSS data URI, or download the whole batch as a .zip.

What the Optimizer Removes

WhatExampleEffect
Editor metadataSketch, Illustrator and Inkscape attributes, <metadata>, commentsOften 20–50% of an exported icon.
Over-precise numbers10.500000 → 10.5, path data rewritten with relative commandsThe biggest win on paths.
Default valuesfill-rule="nonzero", stroke="none" on shapes that inherit itSafe: the browser assumes them anyway.
Useless groups<g> wrappers with no attributes, empty <defs>Flatter, smaller markup.
Shapes as paths<rect>, <line>, <polygon> → <path> when shorterFewer bytes, same pixels.
Scripts<script> elements and on* event attributesRemoved here on purpose, for safety.

Use the Same Settings in Your Build

To optimize on every build instead, install SVGO and save the settings as a config file:

// npm i -D svgo   then:  npx svgo -f ./icons
// svgo.config.mjs
export default {
  multipass: true,
  floatPrecision: 2,
  plugins: [
    'preset-default',
    'removeScripts',
    // 'removeDimensions', 'prefixIds', ...
  ],
};

Next step for icons: turn the optimized file into a component with the SVG to JSX converter, or make PNGs and a favicon with SVG to PNG. To inline an image as Base64 instead, try Image to Base64.

Need an icon to start from? Browse Material Symbols, Lucide, Heroicons, the free CC0 icon packs or this week's new icons.

Frequently Asked Questions

Which version of SVGO does this use?
SVGO 4, the same engine as the svgo npm package and SVGOMG, running entirely in your browser. The settings map to the preset-default plugins plus the toggles shown, so you can copy them into an svgo.config.mjs file.
Will optimizing change how my SVG looks?
At the default precision it should look identical. Very low precision (0 or 1) can shift curves on large artwork, so compare the before and after previews. Keep 3 or more decimals for detailed illustrations and maps.
Does it keep the viewBox?
Yes. SVGO 4 no longer removes the viewBox or the title by default, so the SVG still scales and stays accessible. Turn on Remove width/height to make it scale purely with CSS.
What is the gzipped size?
Servers usually send SVG compressed with gzip or Brotli, so the gzipped size is closer to what users download. The tool measures it with your browser’s CompressionStream API.
When should I use Prefix IDs?
When you inline several SVGs in one HTML page. Two icons that both define id="a" for a gradient or clip path will clash; prefixing makes every ID unique.
Is it safe to optimize SVGs from unknown sources?
The tool always removes script elements, and the previews show the SVG as an image, where scripts cannot run. Still, check SVGs from untrusted sources before you inline them in a page.

Sources & Standards

Last reviewed .

Related Tools