npm / svgo
svgo
What changed in svgo 1 to 4, from its official release notes, upgrade guides and advisories. Sources checked 2026-11-30.
51 breaking7 security17 new APIs and options5 performance8 behavior and defaults2 tooling25 fixes and other
See which of these apply to your code, ranked, in your agent:
npx @unstale/cli initsvgo 457 changes
Breaking changes 20
Invalid XML numeric character references in text and attributes are now rejected; valid XML documents remain unaffected.
Plugin and preset types now enforce that a preset name starts with
preset-.The array of built-in plugins is available as a top-level export from svgo.
Color references other than ID references are now converted to lowercase by default; set convertCase to false to disable this.
The public API no longer has default exports; replace default imports with named exports or a namespace import.
ESM and browser usage must use named imports; CommonJS continues to support default and named exports.
This function is not exported from the browser bundle.
Import from svgo; pass a third argument containing the relevant node tree when selectors depend on parent or sibling nodes.
Paths are no longer merged when attributes or styles depend on the node's bounding box.
Transforms are no longer moved when the group has a filter attribute.
SVGO now requires Node.js >=16.0.0.
Stringified path data now includes a space before numbers represented in scientific notation.
Import from svgo; pass a third argument containing the relevant node tree when selectors depend on parent or sibling nodes.
Queries on a child node use that node and its descendants as context by default; pass rootNode when results may depend on parent or sibling nodes.
The plugin name was replaced by removeScripts; update SVGO configuration that refers to the old name.
The removeScriptElement plugin is renamed to removeScripts, which also removes event handlers and script URIs.
removeTitle is no longer enabled by preset-default; configure it explicitly to continue using it.
Nodes are no longer removed when a child element has an ID.
removeViewBox is no longer enabled by preset-default; configure it explicitly to continue using it.
Use svgo/browser as the public import path for browser usage instead of importing the browser bundle from an internal dist path.
Security 5
Filters executable data URLs containing HTML, XHTML, or SVG documents and legacy vbscript URLs, while preserving inert data such as PNG images.
Sanitizes SVG foreignObject content by removing HTML event-handler attributes, srcdoc, and executable URLs from specified URL-bearing attributes.
Recognizes namespace-prefixed SVG a elements and removes ASCII tabs and newlines before checking URL schemes, preventing obfuscated script URLs from bypassing detection.
SVGO removeScripts plugin leaves some executable scripts intact
SVGO DoS through entity expansion in DOCTYPE (Billion Laughs)
New APIs and options 7
SVGO is now a dual package serving both CommonJS and ESM usage.
A parameter was added to convert colors to a common casing, either lowercase or uppercase.
This helper creates the node-to-parent Map needed as the third argument to selector helpers.
Plugins now have isPreset and plugins properties; presets identify themselves and expose their constituent plugins in invocation order.
Import from svgo; pass a third argument containing the relevant node tree when selectors depend on parent or sibling nodes.
A new plugin removes deprecated SVG attributes and is disabled by default.
A runtime export lets applications retrieve the SVGO version.
Performance 4
Speeds up child node removal.
Reduces redundant equality checks.
Computes styles lazily.
SVG parsing now uses string methods instead of a regular expression.
Behavior and default changes 5
Plugin listings no longer include whether plugins are enabled or disabled by default; the argument appends each plugin's presets to the end of its line.
URI-encoded and non-URI-encoded IDs are now treated as the same.
Group collapsing now checks styles as well as attributes and moves attributes atomically.
Preset plugins expose their constituent plugins in the order they are invoked.
The plugin now removes Boxy SVG and Krita namespaces.
Tooling 1
Type declarations are generated from JSDoc, making them more accurate, documented, and synchronized with the implementation.
Fixes and other changes 15
Parser failures are consistently exposed as SvgoParserError errors with an Invalid character entity reason.
Improves parsing of negative or positive arc radii.
Skips case-normalization for CSS custom properties.
Improves handling of consecutive
tcommands.Handles paths more safely.
Encodes a value as a data URI only once when converting to a data URI.
Logs a warning and does nothing when parameters are missing.
Removes JavaScript URIs case-insensitively and handles <script> elements in a namespace-aware way.
Prevents leftover <use> elements from referencing an empty container that was removed.
Preserves attributes referenced in CSS attribute selectors.
Fixes handling of a quadratic control point when an item is removed and preserves vertices for marker-only paths.
SVGO no longer crashes when the output argument ends with a trailing slash to a location that does not exist.
Fixes cases where IDs were not prefixed when a style tag contained XML comments.
Empty containers with filters applied via CSS are no longer removed.
Nodes are retained when child elements have referenced IDs, and path elements with zero opacity are treated as non-rendering.
svgo 323 changes
Breaking changes 17
cleanupIds no longer accepts the prefix parameter; use prefixIds after cleanupIds to add prefixes.
The cleanupIDs plugin was renamed to cleanupIds, so configurations using the old name must be amended.
createContentItem is removed; nodes are now plain objects, with parentNode needing to be defined to preserve builtin plugin behavior.
The helper utility was removed; disable plugins enabled by preset-default through its overrides parameter instead.
The JSAPI class is removed from nodes; nodes are now plain objects, with parentNode needing to be defined to preserve builtin plugin behavior.
SVGO now requires Node.js >=14.0.0.
Optimization errors are now thrown; parsing errors can be identified by the SvgoParserError name.
The optimization result no longer includes error or modernError; exceptions are thrown to the caller.
The optimization result no longer includes height; it can be obtained with a custom plugin.
The optimization result no longer includes info, so it no longer returns the SVG width and height.
The optimization result no longer includes modernError; errors are thrown instead.
The optimization result no longer includes width; it can be obtained with a custom plugin.
The plugin.active flag is removed.
Default parameters are no longer provided through plugin.params; destructuring with defaults can be used instead.
Plugins in the plugins array no longer accept active; a plugin is enabled if it is named and disabled if it is not named.
The sortAttrs plugin is now enabled by default to improve gzip compression; it can be disabled through the SVGO config.
Only the visitor plugin API is supported; plugins using full, perItem, or perItemReverse must be migrated.
Security 1
Hardens handling of executable data: and vbscript: URLs, executable HTML in <foreignObject>, namespace-prefixed SVG anchors, and URL schemes containing ASCII tabs or newlines.
New APIs and options 1
Use prefixIds to add ID prefixes, placing it after cleanupIds or cleanupIds will remove the prefixes again.
Tooling 1
SVGO now bundles TypeScript declarations, so users who depended on @types/svgo should uninstall it.
Fixes and other changes 3
SVGO no longer throws an error when encountering comments in DTD.
Fixed the datauri option when multipass is not enabled.
Default preset warnings were improved.
svgo 214 changes
Breaking changes 10
The flag specifies a JavaScript config file, which may have any name; inline JSON config is no longer supported.
The CLI no longer accepts the --disable flag.
The CLI no longer accepts the --enable flag.
Node.js 10.13 or later is required to run SVGO 2.0.
Loading custom plugins by path in plugin configuration is no longer supported; import or require the plugin manually.
Plugin configuration now uses objects with a name and optional params instead of the previous name-as-key format.
The default behavior is to run only the plugins specified in the plugins list; use extendDefaultPlugins to extend the default list.
The CLI searches for svgo.config.js by default; YAML and JSON configuration files are no longer supported.
The SVGO class is replaced by the optimize function.
The Node API is synchronous, so optimization results can be used without promises or callbacks.
Security 1
Hardens removal of script elements by removing known SVG event attributes, rejecting executable data: and vbscript: URLs, sanitizing executable HTML inside foreignObject elements, and handling namespace-prefixed anchors and URL schemes containing ASCII tabs or newlines.
New APIs and options 2
A Node API function is available to resolve SVGO configuration using the same logic as the CLI.
An official browser-ready ES module bundle is available, supporting optimize, extendDefaultPlugins, and createContentItem.
Performance 1
The installed package is smaller.
svgo 121 changes
Breaking changes 4
cleanupNumericValues now rounds values in viewBox.
minifyStyles now removes styles based on usage, with controlling options.
SVGO now requires Node 4 or higher.
SVGO.optimize() now returns a Promise.
New APIs and options 7
The new except option keeps specified IDs.
The new force option lets cleanupIDs run even when an SVG contains style or script elements.
The JS API gains a datauri option.
A new plugin converts styles from a style element to attributes when possible.
A separator character in removeAttrs can now be changed with elemSeparator.
A new plugin removes script elements and is disabled by default.
The plugin gains a keepAriaAttrs option.
Behavior and default changes 3
The plugin can now add values to attributes.
SVG 2 href attributes are now supported.
The CLI treats filenames as input, allowing the
svgo *.svgsyntax.
Fixes and other changes 7
Fixed arcs transforming with different signed scale parameters.
cleanupIDs no longer removes IDs when an image consists only of defs.
Parsing now accounts for animation syntax.
The color #ff0000 now converts to red, in addition to #f00.
The colors list now includes the gray variation per CSS Color Module Level 4.
Fixed an error on empty files.
The plugin now checks for style or script elements per file.