Nodes/Api Nodes/String API Node
ComfyUI Node

String API Node

Your Prompt as a Scriptable Parameter

By hypnodes·Created 2 years ago·Updated 7 months ago· 0
String API Node
    • output
    namename
    default_valuedefault value

    If you're going to script ComfyUI at all, the String API Node is probably the first one you'll reach for, because the thing you most often want to change per run is text: the prompt, the negative, a filename, an image tag. This node is a labeled text box whose contents a script can replace before the workflow runs. No API key, no network call, no credits - despite the name.

    A word on the naming so you're not misled: ComfyUI's official "API Nodes" are the paid Partner Nodes that call closed models like Nano Banana and Veo. This pack, hypnodes/ComfyUI_ApiNodes, is the opposite direction entirely - it exposes your workflow's inputs to scripts so an external caller can submit the workflow with different values. Local, free, and the only server it talks to is yours.

    How it works

    Pure pass-through. The node returns default_value unchanged, typed as STRING, and does nothing else. The name field is metadata for the script - it has no effect on the graph itself. When you export the workflow in API format, each node's widget values become entries in inputs; a script edits default_value on the node whose name matches, then POSTs the JSON to /api/prompt. That's the whole trick, and it's fully inspectable.

    If you don't want the JS tooling, a few lines of Python do the same job:

    import json, urllib.request
    
    workflow = json.load(open("workflow_api.json"))
    for node in workflow.values():
        if node["class_type"] == "String API Node" and node["inputs"]["name"] == "prompt":
            node["inputs"]["default_value"] = "a cat in space"
    
    req = urllib.request.Request(
        "http://localhost:8188/prompt",
        data=json.dumps({"prompt": workflow}).encode(),
        headers={"Content-Type": "application/json"},
    )
    urllib.request.urlopen(req)
    

    The author also ships a Node CLI if you prefer that: npm install -g @hypnodes/comfyui-api-nodes, then comfyui-workflow inspect workflow_api.json to list parameters and comfyui-workflow run -o '{"prompt":"a cat"}' workflow_api.json to submit.

    Inputs and outputs

    • name (STRING, default "name") - the parameter key your script matches on. Rename it to prompt or negative so the JSON reads like a config.
    • default_value (STRING, multiline, default "default value") - the text the node outputs. Multiline, so long prompts fit.
    • output - one STRING socket.

    Wiring it up

    Convert a CLIP Text Encode node's positive or negative widget to an input (right-click → Convert to input) and wire this in. Now your prompt has a single authoritative source that a script can overwrite per run, while the editor keeps a sane default. Because the output is typed STRING, it only connects where a string belongs - if you need one knob that can feed any type of socket, that's the Any API Node's job.

    Install

    ComfyUI Manager → search ComfyUI_ApiNodes, or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/hypnodes/ComfyUI_ApiNodes
    

    Restart to load it. Four small files, zero Python dependencies, no models. The CLI is a separate npm package - the nodes themselves need nothing beyond ComfyUI.

    Gotchas

    The pack-wide traps: the script's key must match the node's name exactly (spelling and case), and duplicate names get overwritten by the same value. One specific to this node: a fresh one defaults to the string "default value", which is a harmless but confusing fallback - rename it to something real on day one. And changing the widget updates the default; an API override only lasts for that one submission, which is exactly the behavior you want once you're used to it.

    Categoryapi

    Inputs (2)

    NameTypeDefaultDescription
    nameSTRINGname
    default_valueSTRINGdefault value

    Outputs (1)

    NameTypeDescription
    outputSTRING