JSON Get Array Count (Soze)
How many items, and what's in them
- array_count
- json_item
If you're driving a loop off a JSON array - walking through a list of image URLs, a set of prompt variants, a batch of metadata entries - the very first thing you need to know is how many items you're actually iterating over. JSON Get Array Count answers that, and hands you the array itself at the same time so you're not making a second node do the lookup.
This pairs naturally with JSON Array Iterator elsewhere in the pack: use this node to find out total_items up front (for a loop bound, a batch-count widget, a sanity check before you queue a hundred runs), and the iterator to actually walk through them one at a time.
How it works
You give it a JSON string and a json_path pointing at the array you care about inside that structure. It navigates to that path, counts the elements, and returns the count - plus the JSON value found at that path, serialized back out as a string, so you have both the number and the data without a second round of parsing.
The inputs and outputs that matter
json_input- required, multiline. The full JSON blob.json_path- required, default empty string. Points at the array insidejson_inputyou want counted. If your array is at the top level, this may just need to be left as the root path - worth testing on a small sample first since the exact path syntax isn't spelled out in the schema.- Output:
array_count- how many elements are in the array at that path. Feed this into a loop bound or a batch-count widget elsewhere in your graph. - Output:
json_item- the value found at that path, handed back as a string, so you don't need a separate extractor to get at the array's contents.
How to install it
ComfyUI Manager - search "Quality of Life Nodes for ComfyUI" or "Soze" - or manually:
cd ComfyUI/custom_nodes
git clone https://github.com/SozeInc/ComfyUI_Soze.git
pip install -r ComfyUI_Soze/requirements.txt
Restart after. Pure JSON handling, no models, no GPU work, no API keys needed.
Common issues & troubleshooting
array_count comes back as 0 or errors. The most likely cause is json_path not actually pointing at an array - either the path syntax is wrong or the target field is an object, not a list. Run your JSON through JSON Formatter first to eyeball the structure and confirm exactly where the array lives before pointing this node at it.
You're driving a downstream loop and the count is off by one. Double-check whether your loop logic (an iterator's index, a batch-count widget) is zero-indexed or one-indexed - array_count gives you the raw element count, and it's on you to convert that into the right loop bound depending on how the consuming node counts.
No community thread to check against. This pack has almost no footprint in general ComfyUI discussion, so if the path syntax genuinely trips you up, testing directly against a short sample JSON string will get you an answer faster than searching for one.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| json_input | STRING | — | |
| json_path | STRING | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| array_count | INT | — |
| json_item | STRING | — |