This is a config file to be used with svgo's command line tool.
You can ues it with the following command:
svgo *.svg --config=/PATH-TO-FILE/svgo-config.yml
This is a config file to be used with svgo's command line tool.
You can ues it with the following command:
svgo *.svg --config=/PATH-TO-FILE/svgo-config.yml
{ | |
"plugins": [ | |
{ | |
"cleanupAttrs": true | |
}, | |
{ | |
"removeDoctype": true | |
}, | |
{ | |
"removeXMLProcInst": true | |
}, | |
{ | |
"removeComments": true | |
}, | |
{ | |
"removeMetadata": true | |
}, | |
{ | |
"removeTitle": true | |
}, | |
{ | |
"removeDesc": true | |
}, | |
{ | |
"removeUselessDefs": true | |
}, | |
{ | |
"removeEditorsNSData": true | |
}, | |
{ | |
"removeEmptyAttrs": true | |
}, | |
{ | |
"removeHiddenElems": true | |
}, | |
{ | |
"removeEmptyText": true | |
}, | |
{ | |
"removeEmptyContainers": true | |
}, | |
{ | |
"removeViewBox": false | |
}, | |
{ | |
"cleanUpEnableBackground": true | |
}, | |
{ | |
"convertStyleToAttrs": true | |
}, | |
{ | |
"convertColors": true | |
}, | |
{ | |
"convertPathData": true | |
}, | |
{ | |
"convertTransform": true | |
}, | |
{ | |
"removeUnknownsAndDefaults": true | |
}, | |
{ | |
"removeNonInheritableGroupAttrs": true | |
}, | |
{ | |
"removeUselessStrokeAndFill": true | |
}, | |
{ | |
"removeUnusedNS": true | |
}, | |
{ | |
"cleanupIDs": true | |
}, | |
{ | |
"cleanupNumericValues": true | |
}, | |
{ | |
"moveElemsAttrsToGroup": true | |
}, | |
{ | |
"moveGroupAttrsToElems": true | |
}, | |
{ | |
"collapseGroups": true | |
}, | |
{ | |
"removeRasterImages": false | |
}, | |
{ | |
"mergePaths": true | |
}, | |
{ | |
"convertShapeToPath": true | |
}, | |
{ | |
"sortAttrs": true | |
}, | |
{ | |
"transformsWithOnePath": false | |
}, | |
{ | |
"removeDimensions": true | |
}, | |
{ | |
"removeAttrs": { "attrs": "(stroke|fill)" } | |
} | |
] | |
} |
with this obsolete version it works!
https://www.npmjs.com/package/svgo/v/1.2.0
npm i -g [email protected]
unfortunately doesn't work for me =(
--config Custom config file, only .js is supported
Hello everyone! Is there anyone from 2025? π
If you want to follow up ahaywood tutorial, you have to update svgo-config.js
for SVGO v3+, you might have noticed that some plugins have changed or been removed. Many older configurations no longer work, and you may see errors like:
β Error: Unknown builtin plugin "cleanupIDs" specified.
1οΈβ£ cleanupIDs
has been removed β This plugin no longer exists, so remove it from your config.
2οΈβ£ removeAttrs
now requires an array format β Use { attrs: ["stroke", "fill"] }
instead of a regex.
3οΈβ£ preset-default
includes essential optimizations β No need to manually list common plugins.
4οΈβ£ multipass: true
is recommended β Enables multiple optimization passes for smaller file sizes.
5οΈβ£ The config file must be .js
(not .json
) β Use export default {}
instead of JSON format.
Here's a valid svgo-config.js
for 2025 and beyond:
export default {
multipass: true,
js2svg: {
indent: 2,
pretty: false,
},
plugins: [
"preset-default",
{
name: "removeViewBox",
active: false,
},
{
name: "removeDimensions",
active: true,
},
{
name: "removeAttrs",
params: { attrs: ["stroke", "fill"] },
},
{
name: "sortAttrs",
active: true,
},
{
name: "mergePaths",
active: true,
},
{
name: "convertStyleToAttrs",
active: true,
},
],
};
Run the following command in your terminal:
svgo *.svg --config=/PATH-TO-FILE/svgo-config.js
With this setup, your SVG optimization will be fully compatible with SVGO v3+ in 2025! ππ¨
Hope this helps! If you find new updates, feel free to share.
Something like this should result in a similar configuration for v2.x: