SVG Optimizer
Optimize and minify SVG files with SVGO and export them to PNG.
Install
irm https://raw.githubusercontent.com/chayprabs/localtools/main/svg-optimizer/install.ps1 | iexlocaltools-svg-optimizer updatelocaltools-svg-optimizer uninstall
curl -fsSL https://raw.githubusercontent.com/chayprabs/localtools/main/svg-optimizer/install.sh | bashlocaltools-svg-optimizer updatelocaltools-svg-optimizer uninstall
brew install chayprabs/localtools/localtools-svg-optimizerbrew upgrade localtools-svg-optimizerbrew uninstall localtools-svg-optimizer
scoop bucket add localtools https://github.com/chayprabs/homebrew-localtools; scoop install localtools-svg-optimizerscoop update localtools-svg-optimizerscoop uninstall localtools-svg-optimizer
winget install localtools.SvgOptimizerwinget upgrade localtools.SvgOptimizerwinget uninstall localtools.SvgOptimizer
npm i -g localtools-svg-optimizernpm i -g localtools-svg-optimizer@latestnpm rm -g localtools-svg-optimizer
Opens at http://127.0.0.1:47127 in your browser. Run localtools-svg-optimizer --help for the command line. Set LOCALTOOLS_NO_OPEN=1 to install without opening it.
Direct download
| Platform | File | Size |
|---|---|---|
| Windows x64 | svg-optimizer-1.0.4-windows-x64.zip | 45.0 MB |
| macOS Apple Silicon | svg-optimizer-1.0.4-macos-arm64.zip | 32.0 MB |
| macOS Intel | svg-optimizer-1.0.4-macos-x64.zip | 33.7 MB |
| Linux x64 | svg-optimizer-1.0.4-linux-x64.zip | 42.3 MB |
| Linux ARM64 | svg-optimizer-1.0.4-linux-arm64.zip | 42.6 MB |
SHA-256 checksums are in the release notes; the install scripts verify them for you.
See it
How to use
- Run localtools-svg-optimizer; the page opens at http://127.0.0.1:47127.
- Drop one or more .svg files (or paste SVG markup).
- Pick Safe or Aggressive, plus any toggles: keep viewBox, remove width/height, prefix IDs, multipass, sanitize, PNG width.
- Press Optimize to see before/after sizes and side-by-side previews; download one file, its PNG, or all as a zip.
- From a terminal: localtools-svg-optimizer optimize icons/ -o out/ --sanitize --png 512
FAQ
Will the optimized SVG look different, or break my sprite sheet?
Not with the Safe preset: it runs SVGO's preset-default but keeps every id, <symbol> and <defs> entry, so file.svg#icon links and outside CSS keep working, and tests render every sample before and after with resvg (at most 0.5% of pixels may differ). Aggressive also drops unreferenced ids, symbols and defs, <title>/<desc>, and rounds to 2 decimals.
Is it safe to accept SVG uploads after sanitizing?
Sanitize keeps only drawing elements and removes scripts, event handlers, foreignObject, external links, and any CSS that loads something from outside (url(), @import, @font-face, image-set and similar), after decoding CSS escapes the way a browser does. It is tested against 30 SVG XSS payloads and 59 CSS, namespace and SMIL payloads by inlining the result into a live browser page. Still serve user SVGs with a Content-Security-Policy as defence in depth.
Why did removing the viewBox not happen?
SVGO only removes viewBox when width/height make it redundant (same origin and size). With mm units or a different size it keeps it, because removing it would change scaling. Turning on Remove width/height always keeps the viewBox.
Does anything get uploaded?
No. Everything runs in the local program on 127.0.0.1; it makes no network requests.
Why does text in the PNG use a different font?
PNG export uses resvg with your system's common fonts (Arial, Helvetica, DejaVu, Liberation). Fonts not found there fall back to a default. The optimized SVG itself keeps your font settings.