SVG Optimizer

Run SVGO over an SVG in your browser. An icon copied out of Figma or Illustrator typically loses 50 to 80% of its bytes, mostly editor metadata and coordinates with seven decimal places that no screen can show. SVGO loads on demand the first time you optimize, and the file never leaves the tab.

SVG Input
Optimized SVG
Before
After

1 Where the savings come from

Editor metadata

title, desc, the Sketch and Illustrator namespaces and generator comments. A production icon renders the same without them.

Redundant structure

Wrapper groups with no attributes, empty defs, elements that are never rendered. Design tools nest groups deeply, and the rendered output rarely needs that nesting.

Number precision

17.1045695 becomes 17.1. Coordinates from a design tool carry seven decimals of accuracy that no screen can show.

Default attributes

Exports often write out stroke-width and fill-rule with their default values. Removing them saves bytes and changes nothing on screen.

2 Turn off Remove IDs for scripted or animated SVGs

Remove IDs is on by default because a design export is full of ids that nothing in the file references, and they are often the largest single saving. However, if your SVG is animated with SMIL, styled from an external stylesheet, or manipulated by JavaScript, those ids are how the code finds the elements. Removing them breaks the animation or script without any error. Turn it off for anything interactive.

Remove width/height is off by default. Dropping the two attributes and keeping only the viewBox makes the SVG scale to its container, which is usually what you want for an inline icon. However, an SVG in an img tag with no CSS then renders at a default size instead of its intended one.

3 Lower precision trades accuracy for bytes

Fewer decimals means a smaller file and slightly less accurate curves. At icon sizes, two decimals is invisible and one is usually fine. On a large detailed illustration, going below two shows up as paths drifting and corners that no longer meet. Compare the before and after preview above each time you lower the Precision value.

How to use the SVG Optimizer tool

  1. Paste SVG markup, or load a file with Upload SVG. Markup from Copy as SVG in Figma works as-is.
  2. Precision sets how many decimal places coordinates keep. Two is invisible at icon sizes.
  3. Remove IDs is on by default and is the biggest single saving on a design export. Turn it off if the SVG is animated or scripted.
  4. Remove width/height keeps only the viewBox, so the icon scales to its container.
  5. Compare the Before and After previews at the bottom before you use the result.

How to run SVGO in a project

Command line

npx svgo icon.svg -o icon.min.svg

# A whole folder, in place
npx svgo -f ./icons --recursive

# With a config file so the settings are in git
npx svgo --config svgo.config.js -f ./icons

svgo.config.js

module.exports = {
  multipass: true,
  plugins: [
    {
      name: "preset-default",
      params: {
        overrides: {
          // removing the viewBox breaks scaling; almost never what you want
          removeViewBox: false,
          // keep ids if anything targets them from CSS or JS
          cleanupIds: false,
        },
      },
    },
    { name: "removeDimensions" },          // keep viewBox, drop width/height
    { name: "convertPathData", params: { floatPrecision: 2 } },
    { name: "sortAttrs" },                 // better gzip ratios across a set
  ],
};

removeViewBox is enabled in preset-default in SVGO 3 and is the most common cause of an icon that stops scaling. Override it to false.

In a build

// Vite
// npm i -D vite-plugin-svgo
import svgo from "vite-plugin-svgo";
export default { plugins: [svgo()] };

// Or at import time with SVGR for React
// npm i -D @svgr/webpack
// { test: /\.svg$/, use: ["@svgr/webpack"] }
// SVGR runs SVGO internally and takes the same config.

Common errors and how to fix them

The icon no longer scales after optimizing
removeViewBox stripped it. It is on by default in preset-default. Override it to false, which this page already does.
A SMIL animation or CSS rule stopped working
cleanupIds renamed or removed the ids those rules target. Turn off Remove IDs for anything animated or styled from outside.
Two icons on the same page now collide
The opposite problem: both were optimized separately and got the same short ids, so gradients and clip paths reference the wrong one. Give each a prefix, or inline them as separate files.
Curves look slightly wrong
Precision is too low for the size. Raise it to 3 for a large illustration; two decimals is only invisible at icon scale.
The file barely shrank
It had already been optimized, or it is mostly path data rather than metadata. A hand-written SVG has little to remove; a Sketch export has a great deal.

Good to know

The savings on a design-tool export come mostly from things that were never needed: the title and desc the tool inserts, its own namespace declarations, wrapper groups with no attributes, and coordinates carrying seven decimal places of precision that no display can resolve. It is normal for a Figma icon to lose three quarters of its bytes without a pixel changing.

Specifications and references

This tool follows the specifications below. Read them when you need the exact normative wording, for example to settle an edge case between two implementations.

Frequently Asked Questions

What does it remove?

Editor metadata, comments, empty groups, unused definitions and hidden elements. It also rounds coordinates, shortens colors and collapses transforms. An icon exported from Figma or Illustrator commonly drops by 50 to 80% with no visible change.

Is this the real SVGO?

Yes, the official browser build of SVGO 3, the same optimizer that runs in most build pipelines. The page loads it the first time you click Optimize.

Will it break my animation or my CSS hooks?

It can, so watch one setting. Remove IDs deletes or renames ids, which breaks CSS or JavaScript that targets them and SMIL animations that reference them. Turn off Remove IDs when the SVG is scripted or animated.

Why is precision a trade-off?

Fewer decimal places means a smaller file and slightly less accurate curves. Two or three decimals is invisible at icon sizes; go lower on a large detailed illustration and the paths start to drift.

Can I paste an SVG straight from Figma?

Yes, that is the main use. Use Copy as SVG in Figma, paste it here and click Optimize. The result is usually a fraction of the size and much easier to read.

Related

For raster images, the image converter handles PNG, JPEG and WebP. An SVG is XML underneath, so the XML formatter can pretty-print one, and the favicon generator takes an SVG as its source.

More Image Tools

Browse all image tools

Copied to clipboard!