Compress SVG files

SVGs compress by removing metadata and simplifying paths. They stay crisp at any size and are ideal for icons and illustrations.

Last updated: 2026-03-18

To compress SVG files, run npx optimo icon.svg. Optimo applies ImageMagick-powered compression by default. For stronger reduction, use --lossy or --resize to shrink dimensions — often the single biggest lever for file size.

Start with optimo

First, run optimo on your image file:

npx optimo icon.svg

This is safe: optimo keeps the original if the output isn't smaller.

Two big levers

1) Lossy mode
npx optimo icon.svg --lossy
2) Resize (dimensions)
npx optimo icon.svg --resize w1280

Practical tips

  • Only optimize SVGs you trust; untrusted SVGs can contain unsafe constructs.
  • For icons, prefer SVG over PNG to avoid multiple raster sizes.
  • If you need a bitmap output, convert to PNG/WebP for predictable rendering.

Consider converting

Sometimes the best compression is picking a better delivery format.

Popular conversions

Frequently asked questions

How do I compress SVG files?
Run "npx optimo icon.svg" to compress SVG with lossless optimization. For stronger compression, add --lossy. For size reduction through resizing, add --resize followed by a percentage, dimensions, or target file size.
What is the best way to reduce SVG file size?
The two biggest levers are resizing (reducing dimensions to match display size) and lossy compression. Resizing usually has a larger impact than codec-level compression. Sometimes converting to a more efficient format is the best approach.