Nodes/ComfyUI-JakeUpgrade/Save String List To JSON JK๐Ÿ‰
ComfyUI Node

Save String List To JSON JK๐Ÿ‰

Persist your presets โ€” save a string or list to a JSON file

By jakechaiยทCreated 2 years agoยทUpdated 3 months agoยท 147
Save String List To JSON JK๐Ÿ‰
    • string_output
    โ—„string_inputโ–บ
    โ—„file_pathโ–บ
    โ—„overwritetrueโ–บ
    โ—„save_astrueโ–บ

    ComfyUI workflows are great at using data and terrible at keeping it. Generate a camera trajectory, a prompt list, or a set of per-scene settings, and the moment you close the session it's gone - unless you save it somewhere. Save String List To JSON JK writes a string (or a parsed JSON list) to a file on disk, so your presets survive the restart. It's the write half of the pack's save/load JSON pair, and Jake built it for a very concrete reason: ATI trajectory presets for Wan video workflows.

    What it does

    Four inputs:

    • string_input - the text to save. This can be a plain string or a JSON-formatted list.
    • file_path - the full filesystem path to write to. No path, no save - it prints an error and bails.
    • overwrite (default True) - if False and the file already exists, it skips writing and leaves the existing file alone. This is your "don't clobber my presets" guard.
    • save_as (default True) - if True, it tries to parse string_input as JSON and writes it out pretty-printed (formatted with indentation). If False, it writes the raw string. If parsing fails, it falls back to string mode with a warning rather than crashing.

    It also creates parent directories automatically, which is a small mercy - you don't need to pre-make the folder.

    The output

    string_output echoes back what you gave it. It's a pass-through for convenience (so you can chain a save into the rest of the graph without breaking the wire), not a result you should expect to be different.

    When it's worth it

    The canonical use: generate something expensive or finicky once - a camera path, a beat list, a curated prompt set - and save it. Next session, load it back with the pack's Load String List From JSON JK and skip the regeneration. It's also great for editing presets outside ComfyUI: save a list, tweak the JSON in a text editor, reload, and your workflow picks up the changes without a rebuild.

    Note the v2.7.2 change: it now saves as a list by default rather than a raw string - so if you're passing a list-like string, save_as on is the behavior you want for round-tripping with the loader.

    Install

    cd ComfyUI/custom_nodes
    git clone https://github.com/jakechai/ComfyUI-JakeUpgrade
    pip install -r requirements.txt
    

    No models, pure file I/O. Gotchas are the usual filesystem ones: give it an absolute path (relative paths resolve against the ComfyUI working directory, which is rarely where you think it is), and remember overwrite = False will silently skip - if you save, see no error, and the file looks stale, check whether overwrite got flipped off.

    Category๐Ÿ‰ JK/๐Ÿ“ฆ Misc

    Inputs (4)

    NameTypeDefaultDescription
    string_inputSTRINGString data to save to JSON file
    file_pathSTRINGFull path to JSON file for saving
    overwriteBOOLEANtrueOverwrite existing file if True, skip if False
    save_asBOOLEANtrueIf True, parse string_input as JSON list and save formatted; if False, save as raw string

    Outputs (1)

    NameTypeDescription
    string_outputSTRINGโ€”