SVG Color Extractor
What colors are actually in this SVG? One node, zero guessing
- STRING
You've got an SVG that's supposed to be "red and gold," but it's a traced mess of 25 near-identical oranges, and you need to know exactly what you're dealing with before you can recolor it. SVG Color Extractor answers that question in one shot: it scans the SVG, pulls out every unique fill color, and hands them back as a list of clean hex values. It's the reconnaissance step that makes every other color node in this pack actually usable.
Why it exists
The whole point of svg-suite is converting raster images to SVG and then editing the result. Converted SVGs are full of slightly-off colors - vtracer quantizes, antialiasing leaves faint halos, and you end up with colors you never chose. Before you can confidently map #E8E8E8 to #FFFFFF, you need to know #E8E8E8 exists. This node is that inventory.
The README's own workflow spells it out: extract colors first, then build a color mapping string from the results, then feed it to SVG Color Replacer. The extractor is the front half of that two-step pipeline.
How it works
Feed it one svg_string and it returns an SVG list (note: a list, not a single string) of unique hex fill colors like ["#FF0000", "#00FF00"]. It's looking at fill colors specifically - so if the color only appears as a stroke, or inside a <style> block, it may not show up. The extraction is a straightforward parse of the markup, so results are fast and deterministic.
There are no knobs to turn. One input, one output, done. That's rare in this pack and kind of refreshing.
Install
Standard svg-suite install:
cd ComfyUI/custom_nodes
git clone https://github.com/MushroomFleet/svg-suite
pip install -r requirements.txt
Restart ComfyUI, or use ComfyUI Manager and search "svg-suite". No extra dependencies beyond the pack defaults.
Where people get burned
The output being a list is the thing to remember. If you wire it straight into a plain STRING input expecting a single color, you'll get the whole list jammed in, or a type mismatch. It's designed to feed nodes that consume color lists, or for you to read and copy values from the UI.
Second, this reports fill colors, and only in hex. If you need stroke colors, or you need to know which elements use a color rather than just that the color exists, pair it with SVG Element Selector's element_attributes output to get the full picture. And be aware the extractor reports what's literally in the markup - if your SVG has a <style> block doing the coloring, the colors hiding in there won't be inventoried. For those, SVG Color Manipulation or the Styler family is the better tool. For the 90% case of "what fills are in this converted SVG," this is exactly right.
Inputs (1)
| Name | Type | Default | Description |
|---|---|---|---|
| svg_string | STRING | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| STRING | STRING | — |