opyeb SVGForge

Guides · Tooling

SVGO, a browser optimiser and hand editing: which to use and where each one is risky

Updated 28 Nov 2026 · 9 min read

There are three ways to make an SVG smaller: a command-line optimiser in the build, a browser tool on a single file, or hand editing. They overlap but are not interchangeable. The command-line tool is repeatable and fast across hundreds of files. The browser tool is immediate and keeps the file local. Hand editing is sometimes the only way to fix a geometry problem that no automated pass should touch.

CapabilitySVGO (CLI)SVGForge (browser)Hand editing
Batch over a folderYesOne file at a timeNo
Metadata and namespacesYesYesTedious
Precision controlYesYes, 1–4 decimalsError prone
Path absolute/relative rewriteYes, more aggressiveYes, conservativeRarely worth it
Remove viewBoxOptional plugin, riskyNeverNo
See the result immediatelyNoYesYes
Keeps the file on the machineYesYesYes

What SVGO actually does

SVGO is a collection of plugins run over the parsed tree. removeMetadata, removeComments and removeEditorsNSData handle the invisible surplus. cleanupNumericValues rounds numbers, convertPathData rewrites path commands and can convert curves, mergePaths combines compatible paths, and collapseGroups unwraps groups. removeViewBox is the plugin to watch: it removes the attribute that makes an icon scale.

Aggressive plugins carry risk. mergePaths can change rendering when paths have different fill rules, and convertShapeToPath changes a readable <rect> into path data that is smaller but harder to edit. A config copied from a blog post may enable plugins that were removed, renamed or reordered since. Pin the version, read the config, and run it on one file before the whole set.

A plugin that is harmless on an icon can be destructive on an illustration: merging paths changes fill rules, and rounding is far more visible on a large curve than on a 24 px glyph. Keep separate configs for the icon set and for artwork, and do not assume one config fits both.

Where a browser tool is the right answer

A browser optimiser is the right choice when the file is a one-off, when you want to see the result before downloading it, when the artwork should not be sent to a third-party service, or when you need the same drawing as a React component in the next minute. It is not the right choice for a build pipeline: doing it by hand for every icon does not scale, and a manual step is forgotten.

The safest workflow uses both. Keep the original .svg files, run SVGO in the build with a reviewed config, and use the browser tool when investigating a file that grew, when a designer sends one asset, or when you need to compare precision settings visually. Both should produce byte counts, so you can tell whether a change helped.

Never optimise in place without version control. A pass that removes an id used by a script in another file looks harmless in the preview and fails at runtime.

Sources

Questions

Does SVGO remove the viewBox?

The removeViewBox plugin exists and was enabled by default in older versions, which broke responsive icons. In current versions it is not enabled by default, but a shared config may still turn it on. Check the config before running it across an icon set.

Is a browser optimiser as good as SVGO?

For a single file it is close for the passes that matter most: metadata, namespaces, precision and path rewriting. SVGO has more plugins, can process a directory and fits a build. A browser tool is better when you want to see the result and the before/after size immediately, and when the file should not leave your machine.

What should I check in the diff?

Check that the viewBox survived, that every id still referenced exists, that gradients and masks still resolve, that text elements keep their whitespace, and that the rendered preview matches at the size you ship. A diff that only shows shorter numbers is usually safe; one that removes nodes deserves a look.

Use the optimizer for a one-off file and SVGO in a build; compare the byte counts of both on the same icon.

Open the optimizer

Written against the W3C SVG specifications, MDN and the React and WCAG documentation; every sample in the examples can be pasted into the optimizer linked above.

Back to the guides