SVG Optimize (Scour)
Full Scour control when the presets aren't enough
- STRING
Scour is the long-running Python library for shrinking SVGs, and SVG Optimize (Scour) is a thin, honest wrapper around it - every toggle maps to a real Scour option. If SVG Optimize Presets is the "just do it" button, this is the instrument panel. You reach for it when you need to control exactly what gets stripped, or when a preset did something you didn't want and you need to bisect why.
The toggles that matter
The five required ones are the daily drivers:
- enable_viewboxing - adds/keeps a
viewBoxfor proper scaling. - enable_id_stripping and shorten_ids - the two-edged swords. IDs are markup bloat, but if your workflow selects elements by ID, stripping them destroys your handles. Defaults are
true, and that's the thing most people trip on. - enable_comment_stripping - removes comments.
- indent_type -
none/space/tab. For output destined to be re-edited,spaceortabkeeps it readable.
The optional section is where the real power (and danger) lives: remove_metadata, remove_descriptive_elements (titles/descriptions), strip_xml_prolog, simplify_colors (converts colors to shorter forms), precision (0–10 decimal places for coordinates - the file-size lever), newlines, sort_attrs, group_create, plus strip_ids_prefix / protect_ids_prefix to surgically strip or protect IDs that start with a given string. protect_ids_prefix is the one that rescues you when you have IDs you need and don't want shorten_ids to mangle.
How it works
It builds a Scour sanitizeOptions() object from your inputs and runs scourString(). Output is a single STRING: the optimized SVG. Because it's literally Scour, everything you already know about Scour applies - including the caveat that aggressive optimization can change rendering (collapsing groups, rewriting colors, renumbering or stripping IDs).
Install
Pack standard:
cd ComfyUI/custom_nodes
git clone https://github.com/MushroomFleet/svg-suite
pip install -r requirements.txt
Restart ComfyUI, or via Manager under "svg-suite". Requires Scour; if it's missing, the node prints an error and silently returns your original SVG - the pack's favorite failure mode.
Where people get burned
The README's own recommended pipeline puts optimization last, after compression and editing. Respect that order: optimizing early strips the very IDs and structure you'll want for downstream editing.
And start conservative. The defaults here are more aggressive than the "default" preset (id stripping and comment stripping are on), so this node will visibly change your file even at defaults. If you just want a light pass, drop to SVG Optimize Presets. If you want control, this is the tool - just be deliberate: strip IDs only if nothing references them, and set protect_ids_prefix for the ones that do.
Inputs (17)
| Name | Type | Default | Description |
|---|---|---|---|
| svg_string | STRING | — | |
| enable_viewboxing | BOOLEAN | true | — |
| enable_id_stripping | BOOLEAN | true | — |
| enable_comment_stripping | BOOLEAN | true | — |
| shorten_ids | BOOLEAN | true | — |
| indent_type | COMBO | none | 3 options: none, space, tab |
| strip_xml_prologopt | BOOLEAN | true | — |
| strip_xml_space_attributeopt | BOOLEAN | true | — |
| remove_metadataopt | BOOLEAN | true | — |
| remove_descriptive_elementsopt | BOOLEAN | true | — |
| strip_ids_prefixopt | STRING | — | |
| simplify_colorsopt | BOOLEAN | true | — |
| precisionopt | INT | 50–10 | — |
| newlinesopt | BOOLEAN | false | — |
| sort_attrsopt | BOOLEAN | false | — |
| group_createopt | BOOLEAN | false | — |
| protect_ids_prefixopt | STRING | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| STRING | STRING | — |