Repository navigation
Releases
v4.1.0
This minor release upgrades the SAX parser and introduces stricter XML validation. It also includes important security hardening for removeScripts, dependency updates, and improvements to the test and regression infrastructure.
Support SVGO
If SVGO is valuable to you or your organization, please consider supporting the project on OpenCollective. Your sponsorship helps fund ongoing maintenance and security work.
Stricter XML validation
SVGO now uses sax 1.6.1, upgraded from 1.5.0 (#2257).
The new parser version validates numeric character references against the ranges permitted by XML. Invalid references are now rejected in both text and attributes, including:
- disallowed control characters such as
,, and; - UTF-16 surrogate code points such as
�; - invalid XML code points such as
.
Valid boundary values—including U+0020, U+D7FF, U+E000, U+FFFD, and characters through U+10FFFF—remain supported.
Parser failures are consistently exposed as SvgoParserError errors with an Invalid character entity reason.
This is an intentional behavior change: malformed SVGs that were previously accepted may now produce a parser error, while valid XML documents are unaffected.
Security
The removeScripts plugin has been hardened against several script-execution bypasses:
- Filters executable
data:URLs containing HTML, XHTML, or SVG documents while preserving inert data such as PNG images, and filters legacyvbscript:URLs (#2263). - Sanitizes content inside SVG
<foreignObject>elements by removing HTML event-handler attributes,srcdoc, and executable URLs fromaction,data,formaction,href, andsrc, while preserving non-executable HTML and visual content (#2264). - Recognizes namespace-prefixed SVG
<a>elements and removes ASCII tabs and newlines before checking URL schemes, preventing values such asjava	script:from bypassing detection while preserving elements in unrelated custom namespaces (#2268).
These changes address:
Dependencies
- Upgraded
css-selectto v6 andcss-whatto v7, and updated SVGO's custom selector adapter forcss-selectv6 (#2244).
Project maintenance
@TrySound is back as an active SVGO maintainer.
Many thanks to @KTibow, @SethFalco, and @XhmikosR for maintaining and improving SVGO over the past several years.
Full Changelog: v4.0.2...v4.1.0
v3.3.5
What's Changed
Security
- Backport the
removeScriptElementhardening from SVGO v4 in #2269:- reject executable
data:URLs and legacyvbscript:URLs - sanitize executable HTML inside
<foreignObject>elements - handle namespace-prefixed SVG anchors and URL schemes containing ASCII tabs or newlines
- reject executable
This addresses GHSA-4vpr-x523-8j87 and GHSA-w27v-7q3p-w38r for the v3 release line.
Support
SVGO v3 is not officially supported; please consider upgrading to SVGO v4. This security fix has been backported, but there is no commitment to backport more complex changes in the future.
See the migration guide from v3 to v4.
v2.8.4
What's Changed
Security
- Backport the
removeScriptElementhardening from SVGO v4 in #2272:- remove known SVG event attributes
- reject executable
data:URLs and legacyvbscript:URLs - sanitize executable HTML inside
<foreignObject>elements - handle namespace-prefixed SVG anchors and URL schemes containing ASCII tabs or newlines
This addresses GHSA-4vpr-x523-8j87 and GHSA-w27v-7q3p-w38r for the v2 release line.
Support
SVGO v2 is not officially supported; please consider upgrading to SVGO v4. This security fix has been backported, but there is no commitment to backport more complex changes in the future.
v4.0.2
What's Changed
Security
- removeScripts, remove JavaScript URIs case-insensitively and make
<script>handling namespace aware. By @SethFalco
Bug Fixes
- convertColors, skip case-normalization for CSS custom properties. By @SethFalco in #2213
- convertPathData, improve handling of consecutive
tcommands. By @KTibow in #2156 - convertPathData, safer handling of paths. By @KTibow in #2158
- Improve parsing of negative (or +) arc radii. By @KTibow in #2205
- When converting to a data URI, only encode it as a data URI once. By @johnkenny54 in #2053
Performance
- mergePaths, speed up child node removal. By @mozzie in #2216
Other Changes
- removeAttributesBySelector, log warning and noop if missing parameters. By @KTibow in #2215
v4.0.1
What's Changed
Dependencies
- Sets minimum version of sax (XML parser) to v1.5.0, which improves built-in guards against entity expansion.
Bug Fixes
- removeEmptyContainers, removed leftover
<use>elements referencing an empty container that were removed. By @johnkenny54 in #2051 - removeUnknownsAndDefaults, don't remove attributes if they're referenced in attribute selectors (CSS). By @SethFalco in #2144
Performance
- convertPathData, refactor to reduce redundant equality checks. By @Lorfdail in #1764 and #2135
- removeHiddenElems, compute styles lazily. By @Lorfdail in #1764 and #2135
Other Changes
- Plugins no longer include if they are enabled or disabled by default, as this was written inconsistently. The
--show-pluginsargument appends the presets a plugin is in to the end of the line. By @viralcodex in #2174 - Plugin/preset types to enforce the name start with
preset-if it is a preset (collection of plugins). By @SethFalco in #2178
Metrics
Before and after of the browser bundle of each respective version:
| v4.0.0 | v4.0.1 | Delta | |
|---|---|---|---|
| svgo.browser.js | 780.2 kB | 781.5 kB | ⬆️ 1.3 kB |
v3.3.4
What's Changed
Security
- removeScriptElement, remove JavaScript URIs case-insensitively and make
<script>handling namespace aware. By @SethFalco
Support
SVGO v3 is not officially supported, please consider upgrading to SVGO v4 instead. We've backported this fix as there are security implications, but there is no commitment to do this for more complex changes in future.
Consider reading our Migration Guide from v3 to v4 which should ease the process.
v2.8.3
What's Changed
Security
- removeScriptElement, make
<script>handling namespace aware. By @SethFalco
Support
SVGO v2 is not officially supported, please consider upgrading to SVGO v4 instead. We've backported this fix as there are security implications, but there is no commitment to do this for more complex changes in future.
Consider reading our Migration Guide from v2 to v3 and Migration Guide from v3 to v4 which should ease the process.
v3.3.3
What's Changed
Dependencies
- Migrates from our unsupported fork of sax (@trysound/sax) to the upstream version of sax (sax).
Bug Fixes
- No longer throws error when encountering comments in DTD.
Metrics
Before and after of the browser bundle of each respective version:
| v3.3.2 | v3.3.3 | Delta | |
|---|---|---|---|
| svgo.browser.js | 910.9 kB | 912.9 kB | ⬆️ 2 kB |
Support
SVGO v3 is not officially supported, please consider upgrading to SVGO v4 instead. We've backported this fix as there are security implications, but there is no commitment to do this for more complex changes in future.
Consider reading our Migration Guide from v3 to v4 which should ease the process.
v2.8.2
This is effectively just a re-release of SVGO v2.8.1, but with *.test.js files omitted. It seems something was wrong with the configuration in the v2.8.0 tag and I hadn't noticed it included a few extra files. 😅
We'll deprecate v2.8.1, and I'll include the change log here.
What's Changed
Dependencies
- Migrates from our unsupported fork of sax (@trysound/sax) to the upstream version of sax (sax).
Bug Fixes
- No longer throws error when encountering comments in DTD.
Metrics
Before and after of the browser bundle of each respective version:
| v2.8.0 | v2.8.2 | Delta | |
|---|---|---|---|
| svgo.browser.js | 587.2 kB | 589.2 kB | ⬆️ 2 kB |
Support
SVGO v2 is not officially supported, please consider upgrading to SVGO v4 instead. We've backported this fix as there are security implications, but there is no commitment to do this for more complex changes in future.
Consider reading our Migration Guide from v2 to v3 and Migration Guide from v3 to v4 which should ease the process.
v2.8.1
Deprecated
This release left *.test.js files in the package, which have been omitted in v2.8.2. Sorry for the noise!
What's Changed
Dependencies
- Migrates from our unsupported fork of sax (@trysound/sax) to the upstream version of sax (sax).
Bug Fixes
- No longer throws error when encountering comments in DTD.
Metrics
Before and after of the browser bundle of each respective version:
| v2.8.0 | v2.8.1 | Delta | |
|---|---|---|---|
| svgo.browser.js | 587.2 kB | 589.2 kB | ⬆️ 2 kB |
Support
SVGO v2 is not officially supported, please consider upgrading to SVGO v4 instead. We've backported this fix as there are security implications, but there is no commitment to do this for more complex changes in future.
Consider reading our Migration Guide from v2 to v3 and Migration Guide from v3 to v4 which should ease the process.