Nodes/ComfyUI_DAO_master/SVG Load (fichier → SVG_TEXT)
ComfyUI Node

SVG Load (fichier → SVG_TEXT)

Pull an .svg file into the graph as usable text

By orion4d·Created about a year ago·Updated 12 months ago· 11
SVG Load (fichier → SVG_TEXT)
    • svg_text
    • path
    file_pathinput.svg
    scale1.00
    center_on_viewboxtrue
    scale_canvasfalse
    ensure_viewboxtrue

    SVG Load is the front door of the SVG lane in ComfyUI_DAO_master: it reads an .svg file from disk and hands it to the graph as SVG_TEXT. Without it, your hand-drawn or exported SVG files are just files sitting on disk, useless inside ComfyUI. With it, you can bring an existing logo, a plotter design, or an exported vector into the graph, restyle it, run boolean operations on it, and rasterize it back into an image tensor.

    How it works

    The node reads the file as raw text, parses it with Python's built-in XML tools, and makes three optional adjustments before handing it over:

    • ensure_viewbox (default on) - if the SVG has width/height but no viewBox, it creates one (0 0 w h). This matters more than it sounds: a lot of SVG tooling (including this pack's SVG Preview) needs a viewBox to know the aspect ratio.
    • scale (default 1) - wraps the content in a <g transform="scale(...)"> group. With center_on_viewbox on (default), scaling happens around the drawing's center rather than the origin, so things stay roughly where they were.
    • scale_canvas - additionally multiplies the width/height attributes on the canvas, so the declared dimensions match the scaled content.

    If the XML parse fails (weird doctypes, non-standard files), it gracefully falls back to returning the raw text untouched rather than erroring - a nice touch.

    Inputs and outputs

    Inputs: file_path (default input.svg, so a relative path resolves from ComfyUI's input folder), scale, center_on_viewbox, scale_canvas, ensure_viewbox.

    Outputs: svg_text (the SVG_TEXT content) and path (the absolute file path, just for confirmation). Wire svg_text into SVG Style, SVG Boolean, SVG Preview, or SVG Save.

    Why you'd use it

    Realistically you'll use this when a workflow already produces SVG files - from this pack's own DXF to SVG or another vectorization node - and you want to loop them back into the graph for more processing. SVG_TEXT is this pack's custom string-ish type, so the clean handoff between SVG Load and the other SVG nodes is the whole point.

    How to install

    Part of the orion4d/ComfyUI_DAO_master pack:

    cd ComfyUI/custom_nodes
    git clone https://github.com/orion4d/ComfyUI_DAO_master.git
    pip install lxml     # or pip install -r requirements.txt
    

    Restart ComfyUI. No models, no system tools.

    Common issues

    The most common failure is FileNotFoundError - remember relative paths are resolved against ComfyUI's input folder, so logo.svg means ComfyUI/input/logo.svg, not the folder you last saved to. If the node returns text that downstream nodes choke on, check the file actually parses as XML; the fallback-to-raw-text behavior hides problems rather than explaining them. And if scaling seems to happen around the wrong point, that's center_on_viewbox off - turn it on.

    CategoryDAO_master/SVG/IO

    Inputs (5)

    NameTypeDefaultDescription
    file_pathSTRINGinput.svg
    scaleFLOAT1.000.01–100
    center_on_viewboxBOOLEANtrue
    scale_canvasBOOLEANfalse
    ensure_viewboxBOOLEANtrue

    Outputs (2)

    NameTypeDescription
    svg_textSVG_TEXT
    pathSTRING