Load Text From JSON Array By Index
Grab item number N out of your collected results
- text_value
Append Input To JSON Array File grows a JSON array on disk, one entry per batch item. This is the node that reaches back in and pulls out item number N. If you've been collecting prompts, captions, or LLM outputs into an array, Load Text From JSON Array By Index is how you turn that pile of data back into something the workflow can use - one item at a time, on demand.
It's part of JasonHoku's Lite Text to File Tools pack, and it fills the same "structured read" role as Load Text From JSON From Key, but for arrays instead of key-value objects. Same design philosophy: narrow, predictable, with a fallback so a missing item doesn't wreck the run.
How it works
Two required inputs:
file_prefix- the JSON array file, relative toComfyUI/output/(defaulttext/lite-text.json, matching the append node's default).index- which item to pull. It's an integer, zero-indexed, clamped to a 0–999999 range in the widget. Item 0 is the first thing ever appended; the newest item islength - 1.
Plus one optional input, default_value, with the same semantics as the key-lookup node: return this string instead of an error when the file is missing, the index is out of range, or the file isn't an array at all.
The text_value output is always a string. Stored items that aren't strings get JSON-serialized on the way out, so you never have to handle a surprise dict where you expected text.
The out-of-range trap
Arrays here are append-only, so indices shift constantly as a batch runs. Item 3 isn't stable - after five more appends it's still item 3, but there are now items 3 through 7 that didn't exist when you wired the graph. The failure mode you'll actually hit: an index that was valid when you set it isn't valid anymore, and you get Error: Index 4 out of range (array length: 4). That's exactly what default_value is for - wire it up if there's any chance the array might be shorter than your index expects.
The other trap: it's not an array
If someone points this node at a JSON object (or the file gets overwritten with one), you'll get Error: JSON file is not an array as the output string. The node doesn't crash - it returns the error as data, which means it can silently flow into whatever you feed text_value into. Check your file_prefix matches the append node, not a Save Text Into JSON file.
Installing it
Identical to the rest of the pack:
cd ComfyUI/custom_nodes/
git clone https://github.com/JasonHoku/comfyui-lite-text-to-file-tools
# restart ComfyUI
Or grab "Lite Text to File Tools" via ComfyUI Manager. Standard library only - no pip dependencies, no model files.
Where it fits
Pair it with the append node for a batch that both collects and replays: append each result as it's generated, then pull a specific index into a Show Text or LLM node. For a human-friendly overview of the whole array, the pack's Load From JSON File with array_items format gives you everything as one multi-line string - this node is for when you want exactly one item, precisely.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| file_prefix | STRING | text/lite-text.json | — |
| index | INT | 00–999999 | — |
| default_valueopt | STRING | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| text_value | STRING | — |