SVG Visibility Toggle
Show, hide, or delete layers in your vector
- svg
- meta
Sometimes the fix for a bad vector isn't recoloring or reordering - it's that a path shouldn't be there at all. SVG Visibility Toggle hides or removes SVG elements by selector. One rule like {"selector": "#path7", "visible": false} and that stray contour that's been wrecking your output is gone from the render. It's the simplest editor in the pack and one of the most useful, because vectorized line art almost always contains junk you want out.
How it works
Inputs are svg_string plus two rule options:
visibility_rules_json(default[]) - array of{selector, visible}pairs using the pack's standard selectors:#id,.class,[attr*=value]. The README's example is illustrative:{"selector": "#path0", "visible": true},{"selector": ".shadow", "visible": false},{"selector": "[id*=bg]", "visible": false}.default_visible(default true) - the visibility for anything not mentioned in your rules. Flip it to false and you've inverted the logic: everything hides except what you explicitly keep.remove_hidden(default false) - the decision that matters.falsesetsdisplay:noneon hidden elements (they stay in the file, just invisible);truedeletes them from the SVG entirely. The tooltip spells out the difference.
Outputs: svg (filtered string) and meta (JSON - which elements were hidden/removed, so you can confirm the rules matched what you thought).
When to use hide vs. remove
display:none is non-destructive and reversible - hide a layer now, and a later visibility node can re-show it. It also keeps the file's path numbering intact, which matters if you're styling by index afterward. remove_hidden physically strips the elements out, which shrinks the file and guarantees downstream nodes (laser cutters, plotters) can't accidentally render them - but it renumbers the world: any index-based rules you wrote against the old numbering are now pointing at different paths. Rule of thumb: hide for iteration and layer experiments, remove for the final export when you're sure the junk is junk.
Where it fits
The classic workflow: vectorize → clean up → SVG Group Layout with labels to identify the offender (that's what labels are for) → Visibility Toggle to hide or delete it → reorder + restyle the survivors. It's also a legit layer system: keep all your paths in one SVG and use visibility rules to build a "version A" vs. "version B" of a design from the same source file.
Install
Standard pack install - one package, all nodes:
cd ComfyUI/custom_nodes
git clone https://github.com/TJ16th/TJ_ComfyUI_Lineart2Vector.git
# restart ComfyUI
or ComfyUI Manager → search TJ_ComfyUI_Lineart2Vector. No models, no keys. Pure XML manipulation under the hood, so the pack's heavier dependencies are irrelevant to this node - it just needs the pack installed and ComfyUI restarted.
Where people get burned
The meta output exists because silent no-match is the #1 failure: a selector typo hides nothing and you stare at an unchanged render wondering why. Check meta. Second: forgetting that default_visible affects everything not in your rules - if you only list one rule and set it false, you've hidden the entire SVG except that one path. Third: the renumbering gotcha above - remove elements before doing index-based styling, never after, or every path_indices string you wrote goes stale.
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| svg_string | STRING | — | |
| visibility_rules_jsonopt | STRING | [] | Array of {selector, visible} to control element visibility |
| default_visibleopt | BOOLEAN | true | Default visibility for elements not specified in rules |
| remove_hiddenopt | BOOLEAN | false | Remove hidden elements from SVG (true) or set display:none (false) |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| svg | STRING | — |
| meta | STRING | — |