SVGO Config for Maximum Compression: 300 Icons Tested

The SVGO settings that shrink SVG icons most without breaking them, measured on 300 icons: precision, multipass, IDs, viewBox, plus three tested configs.

Amit Yadav
13 min read
On this page

For most icon sets, the SVGO config that compresses hardest without visible damage is multipass: true, floatPrecision: 2 and preset-default. On our 300-icon test it cut 59.7% of the bytes with no icon flagged as changed, and the default preset alone had already done most of that work.

Everything else depends on how you ship the icons. Inline icons can drop more attributes, multicolor icons need unique IDs, and translucent strokes need mergePaths turned off. We measured each setting on SVGO 4.1.0 so you can see what it costs and what it breaks.

Quick answer

  • Start with multipass, floatPrecision 2 and preset-default. Total bytes fell 59.7% and 0 of 300 icons were flagged.
  • Precision saves the most after the default preset, and it is also what breaks icons. 0 decimals flagged 97 of 300.
  • Multipass added only 0.4% on top of the default preset, not the 10 to 15% this page used to claim.
  • Inlining many gradient icons on one page? Add prefixIds. The default preset alone drew 39 of 40 icons with the wrong colors.
  • removeXMLNS and removeDimensions are for inline SVG only. removeXMLNS rendered 0 of 60 icons in an img tag.

The test

We ran 300 icons through SVGO 4.1.0, 60 each from five sources, then drew every result in Chrome 156 at 16, 24 and 48 px and compared it with the original.

  • Lucide (lucide-static 1.69.0, 24 px grid)
  • Tabler (@tabler/icons 3.50.0, 24 px grid)
  • Phosphor (@phosphor-icons/core 2.1.1, 256 px grid)
  • Flat Color Icons (flat-color-icons 1.1.0, 48 px grid, multicolor)
  • Editor exports: Inkscape files with their metadata still in place, on 16 and 22 px grids

We flagged an icon as changed when a pixel moved by more than 96 of 255 levels on at least 5% of its painted pixels, at any size. That rule catches damage you can see. It ignores small anti-aliasing shifts, so "0 flagged" means no visible break, not identical pixels.

The gzip columns below are the sum of each file compressed alone, which is how separately served SVG files travel. Tested 2026-11-05 on Node 24.

How much SVGO saves depends on the source

The old rule of thumb, "SVGO saves over 50%", only held for the editor exports. Icons from a maintained pack are already clean, so the default preset has far less to remove.

FeatureRaw bytesDefault presetSaved
Editor exports237,47151,65278.2%
Flat Color Icons45,35029,76734.4%
Lucide29,42922,64223.1%
Tabler34,31628,00018.4%
Phosphor28,05827,4422.2%
SVGO 4.1.0 default preset, 60 icons per source

If your icons come from a tidy pack, expect 2 to 35%. If they come straight from a design tool or an AI generator, expect much more. Our AI SVG cleanup test covers that messier case. To try a single file without a config, paste it into the SVG optimizer.

What each setting is worth

This table shows each setting added to, or removed from, the default preset. The preset gives 159,503 bytes for all 300 icons, or 93,459 bytes with each file gzipped alone.

FeatureBytes vs defaultGzip vs defaultIcons flagged
multipass-0.4%-0.2%0
floatPrecision 2-4.7%-3.7%0
floatPrecision 1-12.2%-9.3%1
floatPrecision 0-26.3%-19.1%97
removeXMLNS-6.6%-8.3%see below
removeDimensions-2.4%-1.8%see below
removeTitle-0.4%-0.5%see below
mergePaths force-0.8%-0.1%1
mergePaths off+3.7%+0.3%0
convertPathData off+20.4%+13.1%0
Change from preset-default on 300 icons. Lower is smaller.

Three results stand out:

  • Multipass is close to free, and close to worthless. It saved 0.4% overall and 0.2% on the messy editor set, far from the 10 to 15% we used to claim on this page. It costs little, so we keep it. Do not expect much from it.
  • convertPathData does the heavy lifting. It is in the default preset, and turning it off added 20.4%. Leave it on.
  • Gzip takes back part of what minifying saves. mergePaths force saves 0.8% of the bytes and 0.1% after gzip. Gzip already compresses repeated attributes, so check the gzip number before you accept a risky setting.

Precision: the setting that breaks icons

floatPrecision rounds path coordinates. It is the strongest setting here and the only one that broke many icons.

Five icons at original, precision 2, 1 and 0. Phosphor stays intact at 0 decimals while the Lucide, Tabler and Paper icons distort.

Precision is relative to the viewBox. Rounding to whole numbers moves a point by up to half a unit, which is a small move on a 256 unit grid and a large one on a 24 unit grid.

FeatureGrid16 px24 px48 px
Phosphor256000
Flat Color Icons48004
Lucide2482028
Tabler24122738
Editor exports16 and 2231426
Icons flagged at floatPrecision 0, out of 60 per source

So a global rule would be wrong in both directions. Use 2 decimals on 24 px grids. A 256 px grid can go lower, and Phosphor took 0 decimals without a single flag in this test.

1 decimal saves 12.2% against 4.7% for 2 decimals, but check the output by eye. It flagged 1 icon of 300, and your set may have more fine detail than ours.

Three configs we tested

Save one of these as svgo.config.mjs and run svgo -rf src -o dist --config svgo.config.mjs. Each one flagged 0 of 300 icons. For the inline config, the pixel check put xmlns back, because our test drew icons through img tags.

FeatureBytesSavedGzip, each file
Raw374,624n/a169,033
Files151,09959.7%89,816
Inline137,68563.2%80,514
Multicolor166,35955.6%93,765
All 300 icons under each config

Files: for SVGs served as img tags, CSS backgrounds or sprites. This is the safe default.

export default {
  multipass: true,
  floatPrecision: 2,
  plugins: ['preset-default'],
};

Inline: for SVG markup pasted into HTML or JSX, with size set by CSS or attributes in your component. It is 8.9% smaller than the files config. Do not serve its output as files.

export default {
  multipass: true,
  floatPrecision: 2,
  plugins: [
    'preset-default',
    'removeDimensions',
    'removeXMLNS',
    { name: 'prefixIds', params: { prefixClassNames: false } },
  ],
};

Multicolor: for gradient icons, or icons you draw with translucent strokes. Precision stays at the default and path merging stays off.

export default {
  multipass: true,
  plugins: [
    { name: 'preset-default', params: { overrides: { mergePaths: false } } },
    { name: 'prefixIds', params: { prefixClassNames: false } },
  ],
};
Use .mjs, or a project without type: module

In a package with "type": "module", a svgo.config.js that uses module.exports failed with "ReferenceError: module is not defined in ES module scope". svgo.config.mjs with export default worked. Older guides mention .svgo.yml. SVGO 4.1.0 ignored that file in our test.

Inlined gradient icons need unique IDs

SVGO shortens IDs, so gradient IDs in different files all become a, b and so on. That is harmless for separate files. Once the icons sit in the same HTML document, every url(#a) points at the first a on the page.

We inlined 40 Fluent Color icons on one page and compared each with the same icon drawn alone.

FeatureWrong icons of 40Bytes
Raw files073,096
Default preset3969,523
cleanupIds off072,993
prefixIds with file path076,390
prefixIds with no path39n/a
prefixIds with a prefix function071,196
40 gradient icons on one page, Chrome 156

Ten gradient icons three ways: alone, inlined together with the default preset showing wrong colors, and inlined with prefixIds showing correct colors.

Three traps showed up with prefixIds:

  1. It needs a path. With no path passed to optimize(), every icon got the same prefix__a, and 39 of 40 stayed wrong. The CLI passes the path for you. In your own script, pass it yourself.
  2. It uses the file's base name. a/x.svg and b/x.svg both produced x_svg__a, so same-named files in different folders still collide. Use a prefix function that builds on the full path if your set has those.
  3. It renames classes by default. class="lucide lucide-bell" became class="bell_svg__lucide bell_svg__lucide-bell", which breaks any CSS that targets .lucide. Set prefixClassNames: false, as in the configs above.

Avoid a counter or random prefix. The SVGO docs warn that unpredictable IDs can cause mismatches between server and client HTML in React and frameworks built on it.

This only matters for icons that have IDs. In our five-source test only 8 IDs in 2 editor files survived the default preset. The risk sits with gradient and multicolor packs like Fluent Color.

viewBox, width and height

SVGO 4 keeps the viewBox. SVGO 3's default preset removed it, and guides written for that version tell you to protect it. We drew 60 Lucide and 60 Tabler icons inline with a CSS size at 16 and 48 px, and all 120 came out different under v3's default output compared with v4's.

On v4, removeViewBox: false in overrides now only prints a warning: "You are trying to configure removeViewBox which is not part of preset-default." The migration guide lists removeViewBox and removeTitle as moved out of the preset. Delete that override when you upgrade, and do not add the plugin back. Its own docs warn that it stops SVGs from scaling.

removeDimensions changes layout. It removes width and height, and adds a viewBox if the file has none. Without a CSS size, the same Lucide icon stopped being 24 by 24:

Where the icon sits (600 px wide container)With dimensionsWithout
Block24 x 24600 x 600
img tag24 x 24600 x 600
Flex row beside text24 x 24576 x 576
inline-flex button, no padding24 x 240 x 0

Use it only when your component or CSS always sets the size.

Settings that break things quietly

removeXMLNS breaks standalone files. It saved 6.6%, and inline rendering stayed identical on all 60 icons. In an img tag 0 of 60 rendered, and the same was true for CSS backgrounds. The plugin docs say the same. Use it only for icons you paste into HTML.

mergePaths changes translucent strokes. It joins paths, so lines that cross no longer double up where they overlap. With stroke-opacity: .5 on the SVG, the default preset changed 36 of 60 Lucide icons and 50 of 60 Tabler icons compared with raw. With mergePaths off, 0 Lucide icons changed. Our pixel rule did not catch this, because all those icons were drawn fully opaque in the main test. If you style strokes with opacity, turn it off.

removeTitle is not in the default preset anymore. It saves 0.4%. Titles can carry the accessible name for standalone icons, so read the accessible SVG guide before you remove them.

Where SVGO fits in a faster site

SVGO is one small part of icon performance. Lucide icons averaged 490 bytes raw and 369 after the files config, so saving about 120 bytes per icon only adds up if you ship many of them.

  1. Ship fewer icons first. Import single icons rather than a whole set. Removing an icon you do not use saves more than any setting here.
  2. Pick a delivery method. Inline, sprite or font changes your page weight more than a config does. We measured that in icon fonts vs sprites vs inline SVG.
  3. Check gzip the way you ship. If icons travel together in one bundle or sprite, attribute removal nearly disappears: removeXMLNS saved 8.3% per file but 0.7% across a set, and removeDimensions 1.8% against 0.2%. Precision goes the other way, because rounded numbers repeat more: floatPrecision: 2 saved 3.7% per file and 8.0% across a set.
  4. Delay icons below the fold if you have hundreds. See our guide to lazy loading SVGs.

If you are deciding whether SVG is right at all, SVG vs PNG compares the two formats.

What this test does not cover

  • We rendered in Chrome only. Firefox and Safari were not tested, including for the inline ID results.
  • 60 icons per source is a sample. A set with finer detail may flag at settings that passed here.
  • The editor exports are Inkscape files from one icon theme. Exports from Illustrator, Figma or Sketch may behave differently.
  • The flag rule looks for visible damage, not exact pixels. Check your own hero icons by eye after any precision change.
What is the best SVGO config for icons?
Start with multipass true, floatPrecision 2 and preset-default. It cut 59.7% of bytes on our 300-icon test with no icon flagged. Add removeDimensions, removeXMLNS and prefixIds only if the icons are inlined.
Does SVGO remove the viewBox?
Not in version 4. The removeViewBox plugin left the default preset, so you no longer need an override. SVGO 3 removed it by default, and that changed all 120 icons in our inline test.
Is multipass worth turning on?
It saved 0.4% of bytes overall and 0.2% on messy editor exports. It costs little and flagged no icons, so we keep it, but it is not a major saving.
What floatPrecision should I use?
2 decimals for icons on a 16 to 48 unit grid. 2 flagged 0 of 300 icons, 1 flagged 1, and 0 flagged 97. A 256 unit grid such as Phosphor went down to 0 decimals with no flags.
Why do my icons show the wrong colors after SVGO?
The default preset shortens gradient IDs, so inlined icons share IDs such as a and b. All references then point at the first match on the page. Add prefixIds with a file path or a prefix function.
Where does SVGO look for its config?
The CLI reads svgo.config.mjs, svgo.config.cjs or svgo.config.js, or a file you pass with --config. In our test it ignored .svgo.yml, which older guides still mention.

Related posts

Share this post