ComfyUI Node

JSON to List

Drag a JSON file in, get a list of strings out — dot-notation key and all

By creativeself-kim·Created 10 months ago·Updated 6 months ago· 1
JSON to List
    • strings
    • count
    file_path
    json_string
    key

    ComfyUI has no opinion about your JSON files, which is a problem the moment your workflow wants to be driven by data - a list of prompts, a config of settings, a batch manifest. UtilJsonToList is the generic answer: point it at a JSON file (or paste a raw JSON string), optionally navigate to a specific key, and it flattens what it finds into a STRING list plus a count. It's the utility version of the pack's storyboard-specific SBJsonParser, minus the storyboard opinion.

    How it works

    Two ways in: file_path (relative paths resolve against ComfyUI/input/, absolute paths work as-is) or json_string, which overrides file_path when connected. The key field is the interesting part - a dot-notation path like "prompts.solo" that walks nested objects and arrays. With an empty key it uses the root. Whatever it lands on gets flattened into a flat list of strings: lists pass through, dicts become their values (values are dumped as JSON if they aren't already strings), scalars become a single-element list. So {"prompts": ["a", "b"]} with key "prompts" gives you ["a", "b"], and a nested dict under the key becomes its values in order.

    The inputs and outputs

    • file_path (STRING) - filename relative to input/, or an absolute path.
    • json_string (STRING, optional) - raw JSON; overrides file_path if connected.
    • key (STRING, optional) - dot-notation path, e.g. "prompts.solo". Empty = root.
    • strings (STRING list) - the flattened result.
    • count (INT) - how many items landed in the list.

    Empty or unmatched input returns [""] with count 0 rather than throwing - a blank string in the output is your "nothing matched" signal.

    Where you'd actually use it

    Anytime your workflow should be data-driven: load a batch manifest and feed each entry into a per-item pipeline, pull a list of negative prompts out of a config, or drive a loop from a JSON array. It also pairs with anything in this pack that consumes STRING lists - UtilStringToList's outputs are the same shape, and downstream batch nodes don't care where a list came from. The flatten-dicts behavior is worth remembering: if you key into a dict, you get its values, not key-value pairs - reach for json_string + a different structure if you need the keys.

    Install

    Ships in the IXIWORKS pack - ComfyUI Manager → search ComfyUI-VideoDescription → Install, restart, or clone into custom_nodes/. No extra dependencies - it's stdlib json plus ComfyUI's folder resolution. If your JSON is storyboard-shaped, SBJsonParser gives you the typed per-field lists instead; for everything else, this is the general-purpose lever.

    CategoryIXIWORKS/Utils

    Inputs (3)

    NameTypeDefaultDescription
    file_pathSTRING
    json_stringoptSTRING
    keyoptSTRING

    Outputs (2)

    NameTypeDescription
    stringsSTRING
    countINT