Nodes/ComfyUI-QING/加载文件丨SVG
ComfyUI Node

加载文件丨SVG

Get SVG markup into the graph without touching a browser

By sheengoa·Created about a year ago·Updated 20 days ago· 16
加载文件丨SVG
    • svg_content
    svg_path

    If you're doing anything with vector graphics inside ComfyUI, the first step is getting an SVG into the graph - and ComfyUI has no stock node for that at all. LoadSVG is the QING pack's loader: give it a path to an .svg file, and it returns the raw SVG markup as a string. One input, one output, and it quietly solves a problem the stock UI doesn't acknowledge exists.

    It's from ComfyUI-QING (display name "加载文件丨SVG"), part of the pack's three-node SVG section alongside SVGToImage (rasterize SVG → PNG/JPG) and SVGSaver (write SVG text to a file).

    How it works

    You type or wire one input - svg_path. The node resolves it with some care:

    • Absolute path → used directly.
    • Relative path → resolved against ComfyUI's input/ directory (the standard folder_paths.get_input_directory()), not against the current working directory. That's a real difference from the pack's LoadPathText, which demands absolute paths - here, relative means "inside input/."
    • It also cleans invisible Unicode characters out of the path - the bidi marks and zero-width characters that sneak in when you copy a Windows path or text from a chat app. If you've ever pasted a path and gotten "file not found" while the path looks correct, this node is already handling that for you.

    The output is svg_content - the file's contents as a STRING, exactly as written. It does not validate the SVG structure, and importantly, it does not rasterize anything: this is a text loader, not a renderer. If your goal is a PNG, wire svg_content into the pack's SVGToImage next. If your goal is a saved file, SVGSaver is the other end of the journey.

    Where it fits

    The realistic flow in the QING world: LoadSVG → modify the markup if needed → SVGToImage for a PNG, or SVGSaver to write it back to disk. If you're rasterizing SVG assets for a compositing pipeline, or vectorizing bitmaps with ImageToSVG and want to inspect the raw output before saving, this is the loader that gets the text in front of you. The one thing to be honest about: raw SVG text is not a pleasant thing to eyeball on canvas - the string is useful to process, not to read.

    Installing

    Part of ComfyUI-QING. ComfyUI Manager: search "ComfyUI-QING". Or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/GAO-SHIQING/ComfyUI-QING
    cd ComfyUI-QING
    python install_dependencies.py   # or: pip install -r requirements.txt
    

    Restart ComfyUI. For the load step you don't even need the optional SVG renderers, but if you want to rasterize what you load, keep cairosvg installed (it's in requirements.txt and the README recommends it for best rendering quality). No model downloads. China mirror: --mirror --auto. Python ≥ 3.9.

    Gotchas

    Missing file → the node raises an exception ("文件不存在: ..."), unlike LoadPathText which politely returns an error string. That's a design inconsistency in the pack you should know about: this node will throw into the console, so double-check the path before queueing. The relative-vs-absolute resolution is the other gotcha - a path like icons/logo.svg resolves against input/, so if you're pointing at a file elsewhere on disk, give it an absolute path. And remember the output is raw text; if a downstream node expects an actual SVG document object rather than a string, you'll need conversion - within this pack, strings are the lingua franca, so you're fine.

    CategoryQING/输入输出

    Inputs (1)

    NameTypeDefaultDescription
    svg_pathSTRING

    Outputs (1)

    NameTypeDescription
    svg_contentSTRING