SVG Element Selector
The inspector tool for SVGs you didn't create
- STRING
- INT
Every SVG you didn't hand-write is a mystery box. How many paths are in there? Do the shapes even have IDs? Is that green a fill or a stroke? SVG Element Selector is the flashlight - it parses the SVG, finds elements matching a selector, and reports on them. It's the reconnaissance node that tells you whether the rest of your editing pipeline is even feasible.
What it reports
Give it an svg_string, a selector (a tag name like path, circle, rect), and an output_type:
- element_count - "how many match." The default, and genuinely the most useful for planning.
- element_ids - lists every ID (or
[no-id]for the unfortunates). This is how you find out whether the file uses IDs at all before you try ID-based editing. - element_classes - the class names in use.
- element_attributes - full attribute dump per element (
Element 0: path - d="..." fill="#FF0000"). The forensic mode. - selected_elements - the raw markup of matching elements.
You can also narrow with attribute_filter, either fill=#FF0000 (exact value) or just fill (attribute exists). That turns the node into "show me every element with a fill attribute," which is perfect for auditing color work before you run a replacer.
Two outputs
The node returns both a STRING (the human-readable report) and an INT (the match count). The count output is the sneaky useful one - you can wire it into a condition or use it to decide whether your selector actually hit anything before you bother piping the SVG onward. This is one of the few svg-suite nodes with a numeric output, and it makes it scriptable in a way the pure-string nodes aren't.
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". Uses lxml from the pack requirements.
Where people get burned
The selector is a tag name, not a full CSS selector language - path works, path.special won't. If the file uses namespaced tags (some exports do), matching can get finicky. And the reports are text: don't expect structured JSON out of this for downstream automation - if you need parsed structure, the element_attributes text is meant for your eyes, not for a parser.
One more: a converted SVG with no IDs and no classes will make element_ids and element_classes return nothing but [no-id] lines. That's not the node failing - it's telling you the file lacks hooks, and you should add them (via SVG Attribute Manipulation's add_class / add_attribute) before trying selector-based editing downstream.
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| svg_string | STRING | — | |
| selector | STRING | path | — |
| output_type | COMBO | element_count | 5 options: element_count, element_ids, element_classes, element_attributes, selected_elements |
| attribute_filteropt | STRING | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| STRING | STRING | — |
| INT | INT | — |