Nodes/ComfyUI-Ollama-Describer/πŸ“ Json Property Extractor πŸ“
ComfyUI Node

πŸ“ Json Property Extractor πŸ“

Pull one field out of a structured LLM response

By alisson-anjosΒ·Created 2 years agoΒ·Updated 5 months agoΒ· 123
πŸ“ Json Property Extractor πŸ“
    • selected_value
    β—„json_input{}β–Ί
    β—„property_pathβ–Ί

    The nodes in this pack that call Ollama - Image Describer, Video Describer, Text Describer, Image Captioner - all have an optional structured_output_format field, where you hand Ollama a JSON schema (or a Python dict) and it constrains its response to match that shape instead of writing free-form prose. This node is the other half of that pattern: once you've got a structured JSON string back, use this to pull out one specific value instead of passing the whole blob downstream.

    Say your structured_output_format asked for {"subject": ..., "background": ..., "mood": ...} - without this node you'd get a JSON string and have to parse it yourself somewhere else in the graph. With it, you point at background and get just that value out, ready to drop into a CLIPTextEncode or wherever it's actually needed.

    How it works

    It's a straightforward path-based extractor: give it a JSON string and a property path, and it walks into the parsed structure and returns whatever's at that key. Nothing fancier than that - no transformation, no formatting, just extraction.

    The inputs and outputs that matter

    • json_input (default "{}", multiline) - the JSON string to extract from. In practice this is almost always wired from one of the Ollama describer/captioner nodes' result output, when that node's structured_output_format was set.
    • property_path - which key (or nested path) to pull out. The node doesn't ship a documented path syntax in its schema beyond the field itself, so the safe approach is a plain top-level key name for a flat structure; for nested JSON, test with a simple example first to confirm how deep paths are expressed before relying on it in a batch job.
    • Output is a single selected_value STRING - the extracted value, ready to wire anywhere a plain string is expected.

    How to install it

    Ships as part of the same pack as the Ollama describer nodes - you don't install it separately. Via ComfyUI Manager, search "ComfyUI-Ollama-Describer" and install. Manually:

    cd ComfyUI/custom_nodes
    git clone https://github.com/alisson-anjos/ComfyUI-Ollama-Describer.git
    pip install -r requirements.txt   # or install.bat on Windows
    

    Restart ComfyUI. This node has no Ollama dependency of its own - it's pure JSON parsing, so it works even if you're feeding it JSON from somewhere else entirely, not just this pack's LLM nodes.

    Common issues & troubleshooting

    The most likely failure is a mismatch between what you asked the LLM for in structured_output_format and what it actually returned - local models don't always honor structured-output constraints perfectly, especially smaller or weaker ones, and a malformed or incomplete JSON response will make extraction fail or return nothing useful. If you're getting empty results, print or inspect the raw result string from the upstream Ollama node first to confirm it's actually valid JSON before blaming this node. And keep property_path in sync with your schema - if you rename a key in structured_output_format, the extractor needs the matching update or it'll be looking for something that no longer exists.

    CategoryCustom Nodes/JSON

    Inputs (2)

    NameTypeDefaultDescription
    json_inputSTRING{}β€”
    property_pathSTRINGβ€”

    Outputs (1)

    NameTypeDescription
    selected_valueSTRINGβ€”