Nodes/ComfyUI-Desert-Pixel-Nodes/DP Create JSON File
ComfyUI Node

DP Create JSON File

Turn a pipe-delimited table into a JSON file on disk

By DesertPixelAi·Created 2 years ago·Updated about a year ago· 25
DP Create JSON File
    • json_text
    • log_info
    file_namemy_json_file
    save_pathoutput\json
    line_separator|
    json_dataindex | name | prompt 00 | comics | sketchy comics art, minimal illustration 01 | anime | colorful anime style, vibrant colors 02 | realistic | photorealistic rendering, high detail
    save_filetrue
    overwritefalse

    This one's a workflow-plumbing node, not a generation node. You type a little table into it - rows and columns separated by pipes - and it writes out a proper JSON file to disk, plus hands you the JSON as a string. If you're building batch runs, prompt libraries, or a config that some other node reads back later, this is the "author it once, save it" step.

    The default json_data tells you exactly what it's for:

    index | name | prompt
    00 | comics | sketchy comics art, minimal illustration
    01 | anime | colorful anime style, vibrant colors
    02 | realistic | photorealistic rendering, high detail
    

    First line is the header (the keys), every line after is a record. Out comes a JSON array of objects keyed by those column names. It's a spreadsheet-in-a-textbox that becomes structured data.

    The inputs that matter

    • json_data (multiline) - your table. First row = column names, one record per line, cells split by the separator.
    • line_separator (default |) - the delimiter between cells. The pipe is a good default because it almost never shows up inside a prompt; if your text contains pipes, change this to something you're not using.
    • file_name (default my_json_file) and save_path (default output\json) - where it lands. That default path is written Windows-style with a backslash; on Linux/Mac it'll still resolve relative to your ComfyUI output folder, but if you care where the file goes, set the path explicitly.
    • save_file (default true) - actually write to disk. Turn it off and you still get the json_text output without leaving a file behind.
    • overwrite (default false) - off means it won't clobber an existing file of the same name. Leave it off until you specifically want to replace.

    Outputs are json_text (the JSON as a string, for chaining into whatever reads it) and log_info (a status line telling you what it wrote and where).

    How to install it

    ComfyUI Manager: search ComfyUI-Desert-Pixel-Nodes, install, restart. Manual:

    cd ComfyUI/custom_nodes
    git clone https://github.com/DesertPixelAi/ComfyUI-Desert-Pixel-Nodes
    

    then restart. Pure Python utility - no models, no special dependencies. Find it under the "DP" utils category.

    Common issues & troubleshooting

    The file didn't appear. Two checks: save_file has to be on, and overwrite has to be true if a file with that name already exists (otherwise it skips the write to protect what's there). The log_info output will tell you which case you hit - wire it to a text preview and read it.

    Rows came out with wrong columns. Your data has a stray separator inside a cell. If a prompt contains a |, the node splits on it and your columns shift. Change line_separator to a character your text never uses.

    I can't find where it saved. The default save_path is relative and written with a backslash. Set an explicit path you recognize, run once, and read log_info for the resolved location before assuming it failed.

    Do I even need this? If you're doing one prompt at a time, no. It earns its place when you're driving a batch from a table - author your variants as rows here, save once, and feed the JSON to whatever loops over it. For a single throwaway list, a plain text node is less ceremony.

    CategoryDP/utils

    Inputs (6)

    NameTypeDefaultDescription
    file_nameSTRINGmy_json_file
    save_pathSTRINGoutput\json
    line_separatorSTRING|
    json_dataSTRINGindex | name | prompt 00 | comics | sketchy comics art, minimal illustration 01 | anime | colorful anime style, vibrant colors 02 | realistic | photorealistic rendering, high detail
    save_fileBOOLEANtrue
    overwriteBOOLEANfalse

    Outputs (2)

    NameTypeDescription
    json_textSTRING
    log_infoSTRING