Mie Loop Cleanup JSON ๐
Clear per-iteration JSON scratch files in a loop
- loop_ctx
- loop_ctx
- cleaned
The JSON member of MieNodes' loop-cleanup family. Loops that track state or write metadata tend to drop a .json file per iteration - a state snapshot, a per-item metadata sidecar, a config dump. MieLoopCleanupJSON clears those as the loop runs so they don't pile up alongside your real outputs.
It's part of ComfyUI-MieNodes (ComfyUI_MieNodes), MieMieeeee's utility pack, under ๐ Loop.
Why you'd reach for it
JSON is the natural scratch format for a loop that remembers things. The pack's own MieLoopBodyOut carries accumulated state as a JSON string, and it's common to persist that - or per-item metadata - to disk each pass so you can inspect or resume it. That's useful while the loop runs and clutter once it's done: a folder with several hundred tiny .json files is exactly the kind of debris that makes an output directory unreadable.
This node sweeps that debris on the fly. It's the JSON-specific counterpart to the cleanup nodes for images, audio, and text - same idea, scoped to a different file type.
How it works
Same pattern as the rest of the cleanup quartet. It plugs into the loop via the shared MIE_LOOP_CTX context - takes it in, deletes the loop's intermediate JSON files, and passes the context back out so iteration continues. The cleaned boolean tells you whether anything was removed on that pass.
The inputs and outputs that matter
loop_ctx(MIE_LOOP_CTX, required) - the loop context that scopes the cleanup. Thread in and out.loop_ctx(output) - pass onward to keep the loop running.cleaned(BOOLEAN, output) - whether JSON was removed this pass.
Installing it
ComfyUI Manager โ search ComfyUI-MieNodes โ install โ restart. Or:
cd ComfyUI/custom_nodes
git clone https://github.com/MieMieeeee/ComfyUI-MieNodes
then restart. No model download. Nodes appear under ๐ MieNodes.
Common issues & troubleshooting
Careful with JSON you actually want. If your pipeline's real deliverable includes JSON - a metadata file you're building on purpose - make sure it's written as an output, not left in the loop's scratch, before this runs. Cleanup is permanent.
Watch it against resumable state. If you're persisting state_json to disk so a loop can resume where it left off, cleaning it mid-run defeats that. Use this node when the JSON is genuinely disposable per iteration, not when it's your resume point.
cleaned is false. Nothing to delete that pass. Expected.
Loop-scoped, matched set. It relies on the MIE_LOOP_CTX flowing from MieLoopBodyIn to MieLoopBodyOut, and only touches the loop's own scratch JSON - not JSON written elsewhere in the graph. As with the other cleanup nodes, the README covers the loop system lightly, so test on a short run before trusting it with a long one.
Inputs (1)
| Name | Type | Default | Description |
|---|---|---|---|
| loop_ctx | MIE_LOOP_CTX | โ |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| loop_ctx | MIE_LOOP_CTX | โ |
| cleaned | BOOLEAN | โ |