Clear JSON Array File
The reset button your JSON array needs
- status
Append Input To JSON Array File has no undo button. Run a batch twice and your array has doubled, with no way to tell the runs apart. Clear JSON Array File is the reset: it wipes the file back to an empty [] so your next batch starts from a clean slate. That's the whole job, and honestly it's a job worth having a node for - without it, "clear the accumulator" means manually opening the JSON and deleting everything by hand.
It's one of the nine nodes in JasonHoku's Lite Text to File Tools pack, and it only makes sense as a teammate to the array-building nodes around it. On its own it just erases a file.
How it works
Two inputs: file_prefix and trigger. The first is the path relative to ComfyUI/output/ - match it to whatever the append node is using, so the default text/lite-text.json pairs with the default on Append Input To JSON Array File.
The second is where this node gets slightly odd, and it's worth being honest about it: trigger doesn't do anything. It's a plain string widget that defaults to "clear", and the code never reads its value - any content, empty or not, produces the same behavior. It exists as a convenience so you have a wire-able input to sequence execution with. ComfyUI runs nodes in dependency order, not left-to-right, so if you want "clear, then start appending," you wire the append node to consume this node's status output (or the trigger, if you've converted it to an input). The order comes from the connection, not from the string in the box.
Whatever you set trigger to, running the node writes [] to the target file - creating the file and any parent folders if they don't exist. The status output confirms it: ✓ Cleared ....
The one scenario that bites people
Because the trigger value is decorative, a Clear node sitting alone in a workflow with the same file_prefix as your data file will happily erase it every time the graph runs. You probably want it downstream of whatever marks "new run" - a batch start signal, or just a button you execute by hand. Don't leave it mid-graph next to an append node with matching prefixes, or every run becomes: clear, append one item, clear... you get the idea.
Installing it
Same drill as every node in 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" through ComfyUI Manager. No dependencies beyond ComfyUI itself, no models.
Where it fits
Think of it as the "new epoch" button. Wire Clear → Append in sequence and each batch gets its own clean array, which keeps the pack's Load Text From JSON Array By Index node honest when it pulls item N. If your workflow collects results across runs and you've been hand-deleting the file between batches, this is the missing middle step.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| file_prefix | STRING | text/lite-text.json | — |
| trigger | STRING | clear | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| status | STRING | — |