Gathering detailed insights and metrics for svgo
Gathering detailed insights and metrics for svgo
Gathering detailed insights and metrics for svgo
Gathering detailed insights and metrics for svgo
npm install svgo
Typescript
Module System
Min. Node Version
JavaScript (97.94%)
TypeScript (2.06%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
21,798 Stars
1,580 Commits
1,419 Forks
245 Watchers
5 Branches
207 Contributors
Updated on Jul 14, 2025
Latest Version
4.0.0
Package Id
svgo@4.0.0
Unpacked Size
1.38 MB
Size
334.63 kB
File Count
154
Published on
Jun 21, 2025
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
7
SVGO, short for SVG Optimizer, is a Node.js library and command-line application for optimizing SVG files.
SVG files, especially those exported from vector editors, usually contain a lot of redundant information. This includes editor metadata, comments, hidden elements, default or suboptimal values, and other stuff that can be safely removed or converted without impacting rendering.
You can install SVGO globally through npm, yarn, or pnpm. Alternatively, drop the global flag (global
/-g
) to use it in your Node.js project.
1# npm 2npm install -g svgo 3 4# yarn 5yarn global add svgo 6 7# pnpm 8pnpm add -g svgo
Process single files:
1svgo one.svg two.svg -o one.min.svg two.min.svg
Process a directory of files recursively with -r
/--recursive
and -f
/--folder
:
1svgo -rf path/to/directory_with_svgs -o path/to/output_directory
Help for advanced usage:
1svgo --help
SVGO has a plugin architecture. You can read more about all plugins in Plugins | SVGO Documentation, and the default plugins in Preset Default | SVGO Documentation.
SVGO reads the configuration from svgo.config.mjs
or the --config path/to/config.mjs
command-line option. Some other parameters can be configured though command-line options too.
svgo.config.mjs
1export default { 2 multipass: false, // boolean 3 datauri: 'base64', // 'base64'|'enc'|'unenc' 4 js2svg: { 5 indent: 4, // number 6 pretty: false, // boolean 7 }, 8 plugins: [ 9 'preset-default', // built-in plugins enabled by default 10 'prefixIds', // enable built-in plugins by name 11 12 // enable built-in plugins with an object to configure plugins 13 { 14 name: 'prefixIds', 15 params: { 16 prefix: 'uwu', 17 }, 18 }, 19 ], 20};
Instead of configuring SVGO from scratch, you can tweak the default preset to suit your needs by configuring or disabling the respective plugin.
svgo.config.mjs
1export default { 2 plugins: [ 3 { 4 name: 'preset-default', 5 params: { 6 overrides: { 7 // disable a default plugin 8 cleanupIds: false, 9 10 // customize the params of a default plugin 11 inlineStyles: { 12 onlyMatchedOnce: false, 13 }, 14 }, 15 }, 16 }, 17 ], 18};
You can find a list of the default plugins in the order they run in Preset Default | SVGO Documentation.
You can also specify custom plugins:
svgo.config.mjs
1import importedPlugin from './imported-plugin'; 2 3export default { 4 plugins: [ 5 // plugin imported from another JavaScript file 6 importedPlugin, 7 8 // plugin defined inline 9 { 10 name: 'customPlugin', 11 params: { 12 paramName: 'paramValue', 13 }, 14 fn: (ast, params, info) => {}, 15 }, 16 ], 17};
SVGO provides a few low level utilities.
The core of SVGO is optimize
function.
1import { optimize } from 'svgo'; 2 3const result = optimize(svgString, { 4 path: 'path-to.svg', // recommended 5 multipass: true, // all other config fields are available here 6}); 7 8const optimizedSvgString = result.data;
If you write a tool on top of SVGO you may want to resolve the svgo.config.mjs
file.
1import { loadConfig } from 'svgo'; 2 3const config = await loadConfig();
You can also specify a path and customize the current working directory.
1const config = await loadConfig(configFile, cwd);
![]() | |
---|---|
SheetJS LLC | Fontello |
This software is released under the terms of the MIT license.
Logo by André Castillo.
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
30 commit(s) and 9 issue activity found in the last 90 days -- score normalized to 10
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
security policy file detected
Details
Reason
SAST tool is run on all commits
Details
Reason
2 existing vulnerabilities detected
Details
Reason
Found 4/29 approved changesets -- score normalized to 1
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
project is not fuzzed
Details
Reason
Project has not signed or included provenance with any releases.
Details
Score
Last Scanned on 2025-07-07
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More