SVGO
Node.js library and CLI that optimizes SVG files by removing metadata, comments, hidden elements and redundant values, using a configurable plugin system.
SVGO (SVG Optimizer) is a Node.js library and command-line application that reduces SVG file size. SVG files exported from vector editors often contain editor metadata, comments, hidden elements, and default or suboptimal values. SVGO uses configurable plugins to remove or simplify this information; review the resulting assets when choosing optimization settings.
On the command line, svgo one.svg two.svg -o one.min.svg two.min.svg processes individual files. svgo -rf path/to/directory_with_svgs -o path/to/output_directory processes a directory recursively using -r/--recursive and -f/--folder. svgo --help lists the advanced options.
Optimization is done by a plugin architecture. A preset-default bundle of built-in plugins is enabled by default. You can disable or override individual plugins' parameters through overrides, enable other built-in plugins such as prefixIds by name, or write custom plugins inline or import them from another JavaScript file. Configuration is read from svgo.config.mjs or from the --config option, and it also covers options like multipass, datauri output (base64, enc, unenc), and js2svg formatting (indent, pretty).
For programmatic use, the optimize function takes an SVG string and a config object and returns the optimized SVG in result.data. loadConfig resolves the svgo.config.mjs file, which is useful for tools built on SVGO. It is aimed at front-end developers, build-tool authors, and anyone who ships SVG assets.
Installation
# via npm
npm install -g svgo
# via yarn
yarn global add svgo
# via pnpm
pnpm add -g svgo
Alternatives & related tools
semantic-release
Automates releases from CI: derives the next semver version from commit messages, generates release notes, tags Git, and publishes packages via plugins.
AVA
Node.js test runner that runs test files concurrently in isolated processes, with diff-based assertion output, TypeScript definitions, and watch mode.
terminalizer
Terminal session recorder that generates animated GIF images from command-line sessions
release-it
Generic CLI for automating releases: version bumps, git commit/tag/push, changelogs, GitHub/GitLab releases, and npm publishing, with hooks and plugins.
np
Interactive release tool for npm packages that checks the working tree, runs tests, bumps versions, creates tags, publishes, and pushes to Git.
add a badge to your README
Maintain SVGO? Show that it's featured on trmn. The badge links back to this page.
[](https://www.trmn.sh/tools/svgo?utm_source=badge)<a href="https://www.trmn.sh/tools/svgo?utm_source=badge"><img src="https://www.trmn.sh/badge/svgo.svg" alt="Featured on trmn" height="20"></a>