Advanced SVG Compression
SVG files too fat? This node actually shrinks them
- STRING
Your vtracer SVG looks great, and then you open the file and it's 8 MB. Every traced shape is a polygon with thousands of points, and browsers choke on it. That's the exact problem Advanced SVG Compression exists for. It's the one node in svg-suite I'd argue everyone converting images to SVG should run before saving - a traced SVG without this step is like a PNG that was never optimized.
What it actually does
This node wraps the SVGCompress library, and it has three compression modes that target different bloat:
- delete - drops tiny polygons below a size threshold. Great for removing the speckle noise that image tracing loves to leave behind.
- simplify - the interesting one. It runs the Ramer-Douglas-Peucker algorithm over your paths, keeping the shape recognizable while cutting out redundant points. This is where most of your file-size wins come from, and it's the default for good reason.
- merge - combines adjacent or overlapping shapes into single outlines, using either a convex hull or a boolean union.
The distinction matters. Delete is surgical, simplify is the everyday workhorse, and merge is what you reach for when you have dozens of overlapping blobs that could be one clean shape.
The inputs that matter
You only touch a few of these on a normal day:
- compression_type - delete / simplify / merge.
- curve_fidelity - 1 to 50. How faithfully curves are preserved. Too low and things get angular; the default of 10 is a decent starting point.
- selection_threshold - the size cutoff for selecting which polygons get worked on (measured by selection_criteria, either
bboxareaorcircumference). - optimize_after - default
true, and leave it on. It runs a Scour cleanup pass after compressing, which is where you pick up the last bits of savings.
The optional inputs only matter per-mode: simplify_epsilon controls how aggressive the RDP simplification is (higher = smaller and rougher), merge_epsilon and buffer_distance tune merge behavior, and delete_threshold sets what counts as "tiny" for delete mode.
Output is a single STRING - the compressed SVG markup, ready to pipe into SVG Optimize (Scour) or SVG Preview (Advanced).
Install
This is a shared svg-suite node, so install is the same as the rest of the pack:
cd ComfyUI/custom_nodes
git clone https://github.com/MushroomFleet/svg-suite
cd svg-suite
pip install -r requirements.txt
Then restart ComfyUI. On Windows portable, the repo ships an install-portable.bat that targets the python_embeded interpreter. Or just use ComfyUI Manager and search "svg-suite". The heavy dependencies here are SVGCompress and its friends shapely, rdp, and svg.path - they're all in requirements.txt, so a Manager install pulls them automatically.
Where people get burned
The most common issue is expecting miracles. Compression is a quality/size trade, and cranking curve_fidelity to 1 or simplify_epsilon to 20 will absolutely wreck a logo into a blob. Go iterative: run it at defaults, check the preview, nudge down only what looks bad.
Second gotcha: if SVGCompress isn't installed, the node doesn't error - it just returns your original SVG unchanged with a console message. That's the kind of silent failure that makes you think the node "isn't working" when it's actually a missing dependency. Check your console, and check that shapely and rdp came along.
Also worth knowing: this operates on the SVG as a string, which is how all the svg-suite string nodes work - feed it the STRING output of a conversion node, not an image. If you're feeding it an IMAGE you've wired up wrong.
Inputs (13)
| Name | Type | Default | Description |
|---|---|---|---|
| svg_string | STRING | — | |
| compression_type | COMBO | simplify | 3 options: delete, simplify, merge |
| curve_fidelity | INT | 101–50 | — |
| pre_select | BOOLEAN | false | — |
| selection_criteria | COMBO | bboxarea | 2 options: bboxarea, circumference |
| selection_threshold | FLOAT | 300.00.1–10000 | — |
| optimize_after | BOOLEAN | true | — |
| delete_thresholdopt | FLOAT | 100.00.1–10000 | — |
| delete_criteriaopt | COMBO | bboxarea | 2 options: bboxarea, circumference |
| simplify_epsilonopt | FLOAT | 1.00.1–20 | — |
| merge_epsilonopt | FLOAT | 5.00.1–20 | — |
| buffer_distanceopt | FLOAT | 5.00.1–20 | — |
| operation_keyopt | COMBO | hull | 2 options: hull, union |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| STRING | STRING | — |