Nodes/ComfyUI-QING/保存文件丨SVG
ComfyUI Node

保存文件丨SVG

Get that SVG out of the graph and onto disk, with a preview you can trust

By sheengoa·Created about a year ago·Updated 19 days ago· 16
保存文件丨SVG
      svg_content
      filename_prefixcomfy_svg
      save_dir
      overwritedisable
      preview_max_size512

      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:

      1. Validation is a regex, not a parser. It checks that the content contains a <svg tag. 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.
      2. The filename. filename_prefix gets .svg appended if you forgot it, then it's saved.
      3. The save location. By default, files go to ComfyUI/output/svg/. You can override with the optional save_dir (an absolute path, or a subfolder relative to output/svg), or set the COMFY_SVG_OUTPUT environment variable to a directory and every save goes there.
      4. Overwrite handling. With overwrite set to "disable" (the default), a colliding filename becomes name_1.svg, then name_2.svg, instead of clobbering. Set it to "enable" to overwrite.
      5. 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, default comfy_svg. .svg is added automatically.
      • save_dir (optional) - where to write; empty means output/svg.
      • overwrite (optional) - enable / disable; the default disable auto-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 (or pip install cairosvg) in the pack directory and restart.
      • "无效SVG格式" placeholder. The content doesn't contain an <svg tag - you're feeding it something that isn't an SVG.
      • Can't find the saved file. Default is output/svg/ under your ComfyUI install, not output/. Or check for an environment variable COMFY_SVG_OUTPUT you 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.

      CategoryQING/输入输出

      Inputs (5)

      NameTypeDefaultDescription
      svg_contentSTRING
      filename_prefixSTRINGcomfy_svg
      save_diroptSTRING
      overwriteoptCOMBOdisable2 options: enable, disable
      preview_max_sizeoptINT51264–2048

      Outputs (0)

      No outputs