Nodes/Comfyui_PDuse/PDJSON_incrementalnumber
ComfyUI Node

PDJSON_incrementalnumber

Rearrange every node in a workflow JSON into a tidy diagonal stack

By 7BEII·Created 2 years ago·Updated 15 days ago· 53
PDJSON_incrementalnumber
    • result_message
    input_folderA:\1_area\area_python\pojie
    output_folderA:\1_area\area_python\output
    start_x0
    start_y0
    increment20
    file_prefixModified

    ComfyUI workflows are JSON under the hood - the whole graph, node positions included, is a serializable document. PDJSON_BatchJsonIncremental ("PDJSON_incrementalnumber") is a batch editor for that document: point it at a folder of workflow JSONs and it re-positions every node in each one into a neat diagonal cascade, so instead of a rat's nest of overlapping boxes you get a clean left-to-right, top-to-bottom stack. It's the "tidy my graph programmatically" node from the 7BEII/Comfyui_PDuse pack, and it's aimed squarely at people who generate or post-process workflow files in bulk.

    How it works

    For every .json file in input_folder, it loads the workflow, grabs the nodes array, sorts the nodes by their id, and rewrites each node's pos and xy fields to:

    x = start_x + index * increment
    y = start_y + index * increment
    

    So with the defaults - start at (0,0), increment 20 - node 0 lands at (0,0), node 1 at (20,20), node 2 at (40,40), a clean staircase. The files are saved to output_folder as {file_prefix}_{1..n}.json (Modified_1.json by default), so your originals stay untouched. Each file gets processed independently, nodes sorted by ID within that file.

    It also writes the whole thing out as formatted JSON with ensure_ascii=False, which means Chinese labels and prompts survive intact - that matters, because this pack is Chinese-authored and its intended input files often contain Chinese node titles.

    The inputs that matter

    • input_folder / output_folder - the source and destination. Both have default values, and those defaults are literal Windows paths like A:\1_area\area_python\pojie from the author's own machine - you must replace them.
    • start_x / start_y - where the first node lands.
    • increment - how far each subsequent node steps (default 20).
    • file_prefix - the output filename prefix.

    The single output, result_message, is a human-readable report: how many files were processed and the full list of saved paths. Wire it to a Show Text node to read it.

    Installing

    ComfyUI Manager (search Comfyui_PDuse), or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/7BEII/Comfyui_PDuse
    cd Comfyui_PDuse
    pip install -r requirements.txt
    

    Restart afterwards. Nothing to download - it's pure JSON manipulation.

    Gotchas

    A few, all predictable. The default paths are Windows and wrong for you - set both folders explicitly. It processes only .json files, and it expects the ComfyUI workflow format with a nodes array; a raw API-format prompt (which has no nodes key) will get "no nodes found" and be skipped. Sorting is by node id, which is roughly graph order, not visual order, so the resulting cascade is "in ID order," not "in the order you'd draw it." And because it rewrites positions to a straight diagonal, it will happily un-tidy a graph you carefully arranged by hand - run it on copies in output_folder, never in place. If your use case is "my downloaded workflow is a scrambled mess, fix it," this does exactly that; if your workflows are already laid out, you don't need it.

    Categoryimage/PD_jsonincremental

    Inputs (6)

    NameTypeDefaultDescription
    input_folderSTRINGA:\1_area\area_python\pojie
    output_folderSTRINGA:\1_area\area_python\output
    start_xINT0
    start_yINT0
    incrementINT20
    file_prefixSTRINGModified

    Outputs (1)

    NameTypeDescription
    result_messageSTRING