ComfyUI Node

TextToJson

The most honest node in ComfyUI

By Alvaroeai·Created 2 years ago·Updated 2 years ago· 1
TextToJson
    • JSON
    text{"name": "Hotel Comfy", "location": "New York"}

    TextToJson does exactly one thing, and it says so in its name. You paste a JSON string into the multiline text box, it parses that string into a real JSON object, and hands it out of the JSON output. That's the whole job. No API calls, no models, no VRAM, no hidden dependencies - it's a plain Python json.loads() wrapped in a ComfyUI node, and it ships from the Alvaroeai/ComfyUI-Text2Json pack.

    Why would you want that? ComfyUI is a graph where nodes pass typed data around, and plenty of workflows shuffle structured info - prompt metadata, API responses, config blocks - as text. When the thing downstream expects an actual JSON object instead of a string, you need a bridge. This is that bridge. It's a niche utility, honestly: if your workflow never touches JSON, you'll never miss it. But when some LLM node spits out a JSON block and the next node wants a dict, it's the fastest gap-filler around.

    The one input and the one output

    The node is minimal by design - no optional inputs at all:

    • text (STRING, multiline) - the JSON string to parse. It defaults to {"name": "Hotel Comfy", "location": "New York"} just so you can see the shape of what it expects.
    • JSON (output) - the parsed object, ready to wire into anything that consumes the JSON type.

    That's it. One in, one out.

    The gotcha: your JSON has to be actual JSON

    The mechanism is json.loads(), and Python's JSON parser is strict. The two failure modes people actually hit: single quotes ({'name': 'x'}) and trailing commas. Both are legal in JavaScript object literals and both will fail here - JSON demands double quotes and no trailing commas. When parsing fails, the node doesn't throw an error that red-lights your workflow. It quietly returns a JSON object containing {"error": "Invalid JSON string"} instead. That's a double-edged sword: your graph keeps running, but if you're not watching, that error dict flows downstream and does something dumb. Check your output before you chase a bug downstream.

    Installing it

    There's no requirements.txt in the pack - it's pure Python stdlib - so install is a one-liner:

    cd ComfyUI/custom_nodes
    git clone https://github.com/Alvaroeai/ComfyUI-Text2Json
    

    Then restart ComfyUI. ComfyUI Manager might not find this one - it's a tiny pack and Manager's registry coverage is patchy for one-node repos like this - so the manual clone is the reliable path. No model downloads, no extra Python packages, no conflicts. It's the kind of install that works first try, which is more than most packs can say.

    Categoryconversion

    Inputs (1)

    NameTypeDefaultDescription
    textSTRING{"name": "Hotel Comfy", "location": "New York"}

    Outputs (1)

    NameTypeDescription
    JSONJSON