保存文件丨SVG
Get that SVG out of the graph and onto disk, with a preview you can trust
ComfyUI's core save node writes PNGs, not vectors. So when your workflow ends in SVG - a hand-built vector string, output from the pack's ImageToSVG vectorizer, or an SVG piped through a generation step - you need a different exit door. SVGSaver is that door: it takes SVG source text, validates it lightly, writes it to disk, and shows you a rendered PNG preview so you can confirm what you actually saved.
Its display name is "保存文件丨SVG" ("save file / SVG"). It's a pure output node: no outputs, its only job is the side effect of writing a file and surfacing a preview in the UI.
How it works
The mechanism is refreshingly simple, and it's worth knowing the edges:
- Validation is a regex, not a parser. It checks that the content contains a
<svgtag. That's it. A string with<svg>anywhere passes; real structural errors only surface later, at preview time. Don't expect it to catch malformed XML. - The filename.
filename_prefixgets.svgappended if you forgot it, then it's saved. - The save location. By default, files go to
ComfyUI/output/svg/. You can override with the optionalsave_dir(an absolute path, or a subfolder relative tooutput/svg), or set theCOMFY_SVG_OUTPUTenvironment variable to a directory and every save goes there. - Overwrite handling. With
overwriteset to "disable" (the default), a colliding filename becomesname_1.svg, thenname_2.svg, instead of clobbering. Set it to "enable" to overwrite. - The preview. The node renders your SVG to PNG using cairosvg, respects
preview_max_size(default 512, range 64–2048) and the SVG's own aspect ratio, and shows it in the UI. If cairosvg is missing it falls back to the optional svglib/reportlab pair, and if those are missing you get a gray placeholder image that says so.
Inputs that matter
svg_content(required) - the SVG source. Multiline text box, wired from whatever produces your vector.filename_prefix(required) - base name, defaultcomfy_svg..svgis added automatically.save_dir(optional) - where to write; empty meansoutput/svg.overwrite(optional) -enable/disable; the defaultdisableauto-suffixes to avoid clobbering.preview_max_size(optional) - cap for the rendered preview.
Installing it
SVGSaver ships in ComfyUI-QING, the 79-node all-in-one pack:
cd ComfyUI/custom_nodes
git clone https://github.com/GAO-SHIQING/ComfyUI-QING
cd ComfyUI-QING
python install_dependencies.py
Restart ComfyUI afterward. ComfyUI Manager users can just search "ComfyUI-QING". Note that cairosvg is in the pack's requirements.txt, so the standard install gets you real previews - you only hit the gray placeholder if you installed the pack and skipped dependencies.
Common issues
- Gray placeholder saying "SVG库未安装". cairosvg isn't importable. Re-run
python install_dependencies.py(orpip install cairosvg) in the pack directory and restart. - "无效SVG格式" placeholder. The content doesn't contain an
<svgtag - you're feeding it something that isn't an SVG. - Can't find the saved file. Default is
output/svg/under your ComfyUI install, notoutput/. Or check for an environment variableCOMFY_SVG_OUTPUTyou may have set once and forgotten. - Preview says "转换错误" but the file saved. The regex passed but cairosvg choked on the actual SVG - the file on disk is still whatever you gave it, so open it in a browser to verify. This is the price of the shallow validation.
If you're doing any vector work in ComfyUI, SVGSaver is the pack's exit ramp. Just remember the preview is only as good as cairosvg, and the validation is only as deep as a regex.
Inputs (5)
| Name | Type | Default | Description |
|---|---|---|---|
| svg_content | STRING | — | |
| filename_prefix | STRING | comfy_svg | — |
| save_diropt | STRING | — | |
| overwriteopt | COMBO | disable | 2 options: enable, disable |
| preview_max_sizeopt | INT | 51264–2048 | — |
Outputs (0)
No outputs