Prompt JSON:
ComfyUI_Prompt_JSON helps you organize and reuse pairs of positive and negative prompts across your workflows. It stores named prompts in JSON lists inside the Prompt folder under your ComfyUI base directory. You can create a list, retrieve a saved prompt, update an existing one, or select a saved prompt at random. The node also provides a readable snapshot of the entire list, making it useful when you want to keep related prompt variations together.
Prompt JSON Input Parameters:
Prompt List
Selects the prompt list the node will read and save. The options are New List and the .json files currently found in the Prompt folder under your ComfyUI base directory; the available file options depend on what is in that folder when the node interface is populated. Choose New List to create or use a list named through New List Name. No fixed default, minimum, or maximum is specified in the source.
New List Name
Names the list to use when Prompt List is set to New List. Enter a name without the .json extension: the node appends that extension and uses the resulting filename in the Prompt folder. A blank or whitespace-only name causes an error in this mode. This is a single-line string; no default value or character-length limits are specified.
Random
Controls whether the node selects one saved entry at random from the chosen list. When enabled, the selected entry supplies both returned prompts, and the values entered in Prompt Name, Positive Prompt, and Negative Prompt are not used to create or edit an entry. The list must contain at least one entry. When disabled, the node uses Prompt Name to retrieve, add, or update an entry. This is a Boolean setting; the processing code uses False if no value is supplied, but the interface does not declare a default.
Overwrite
Controls what happens when Random is disabled and Prompt Name already exists in the selected list. When enabled, the node can update that entry using the supplied prompt text. When disabled, it retrieves the saved text instead, without replacing it. This setting does not prevent a new prompt name from being added. It is Boolean; the processing code uses False if no value is supplied, but the interface does not declare a default.
Console Log
Controls whether the node prints the selected prompt name, list name, and positive and negative text to the ComfyUI console during execution. Enable it when you want to check which entry was used, especially with random selection; disable it to avoid that additional console output. It is Boolean; the processing code uses False if no value is supplied, but the interface does not declare a default.
Prompt Name
Identifies an entry within the selected list when Random is disabled. Enter an existing name to retrieve or potentially update that entry, or a new name to add an entry. A blank or whitespace-only value causes an error in manual mode. When Random is enabled, the node chooses a saved name instead. This is a single-line string; surrounding whitespace is removed, and no default value or character-length limits are specified.
Positive Prompt
Provides the positive text when you add a new entry or update an existing one. A new entry requires nonblank positive text. For an existing entry, Overwrite must be enabled for this field to replace saved text; leaving it blank preserves the saved positive text. If Overwrite is disabled, the saved text is returned instead. This is a multiline string; surrounding whitespace is removed, and no default value or character-length limits are specified.
Negative Prompt
Provides the negative text when you add a new entry or update an existing one. It may be blank for a new entry. For an existing entry with Overwrite enabled, nonblank text replaces the saved negative text; a blank field preserves an existing nonblank negative prompt, but remains blank if the saved negative prompt is blank. If Overwrite is disabled, the saved text is returned instead. This is a multiline string; surrounding whitespace is removed, and no default value or character-length limits are specified.
Prompt JSON Output Parameters:
positive
The positive prompt text for the entry the node used. This is a string containing either a randomly selected entry’s saved text, an existing entry’s saved or updated text, or the text supplied for a newly added entry. You can pass it to a later workflow step that accepts a positive prompt string.
negative
The negative prompt text paired with positive. This string comes from the same selected or named entry and reflects any update made during execution. It can be empty if the entry has no negative prompt, so an empty value does not necessarily mean the node failed.
full list
A string containing the entire selected list formatted as JSON, including each prompt name and its positive and negative fields. It reflects the list after any addition or update made during execution. This is a readable text snapshot of the list, not an additional positive or negative prompt.
Prompt JSON Usage Tips:
- To build a collection, choose
New List, enter aNew List Name, leaveRandomoff, and supply a uniquePrompt Nameand a nonblankPositive Prompt. Run the node again with another prompt name to add another entry to the same list. - To reuse a saved entry without changing it, select its list, turn
RandomandOverwriteoff, and enter its exactPrompt Name. The node returns the saved positive and negative text even if the prompt text fields contain other text. - To revise an entry, select its list, enter its existing
Prompt Name, and enableOverwrite. Supply a nonblankPositive Promptto replace that field; leave it blank to keep the saved positive text. A blankNegative Promptwill not clear a saved nonblank negative prompt. - To explore variations, populate a list with several entries, enable
Random, and optionally enableConsole Logto see the selected entry in the console. Random selection needs a nonempty list. - Check
full listafter adding or editing an entry to confirm what is stored. The node writes the list file on execution, including when it retrieves an entry.
Prompt JSON Common Errors and Solutions:
'New List Name' is required when creating a new list.
- Explanation:
Prompt Listis set toNew List, butNew List Nameis empty or contains only spaces. - Solution: Enter a list name without the
.jsonextension, or select an existing list fromPrompt List.
The selected prompt list is empty or invalid.
- Explanation:
Randomis enabled, but the selected list contains no entries, or the loaded JSON has no usable top-level data. - Solution: Turn off
Randomand add an entry with a name and positive prompt, then enableRandomagain. Alternatively, choose a populated list.
'Prompt Name' is required when Random is not enabled.
- Explanation: In manual mode, the node needs a name to find, add, or update an entry; the field is blank or contains only spaces.
- Solution: Enter the name of an existing entry or a name for a new one, or enable
Randomto choose from a populated list.
'Positive Prompt' is required when adding a new prompt.
- Explanation: The supplied
Prompt Nameis not already in the list, and the positive text is empty or contains only spaces. - Solution: Enter a positive prompt to create the entry. If you intended to retrieve a saved entry, check its name and selected list.
json.decoder.JSONDecodeError or an error while loading JSON
- Explanation: The selected
.jsonfile cannot be parsed as JSON, so the node cannot read its entries. - Solution: Repair the file’s JSON formatting or restore a valid copy, then try again. Back up the file before editing it manually.
TypeError or KeyError when reading a saved entry
- Explanation: The selected file’s contents do not match the structure the node expects: prompt names should map to entries containing
positiveandnegativefields. A missing field or unexpected value can cause a lookup to fail. - Solution: Check the JSON file and correct the affected entries, or recreate the list through the node. Back up the file before making manual changes.
PermissionError or an error creating or saving a file
- Explanation: The node cannot create the
Promptfolder or read or write the selected list file, commonly because of file permissions or a read-only location. - Solution: Make sure your ComfyUI installation can write to its
Promptfolder and that the selected file is accessible, then run the node again.
