Comfy-UI prompt change in json using comfy-cli
I am using comfy-ui which is world class option. But I am working on the use of comfy-ui json file using comfy-cli. I want to know that how can I change the prompt while using the cli and generate the results? If there is any detailed guide on the edit or change of the prompt would be a great help.
@Tortoise17 comfy-cli has a comfy run command that lets you execute workflow JSON files against a running ComfyUI instance [1]. However, comfy-cli itself does not have a built-in feature for editing prompts programmatically — you'd modify the JSON file manually (or with a script) before running it [2].
Here's the general workflow:
-
Export your workflow in API format from ComfyUI (enable Dev Mode in settings, then use "Save (API Format)"). The JSON should have nodes keyed by ID strings with
class_typeandinputsfields, like:{ "1": { "class_type": "CLIPTextEncode", "inputs": { "text": "your prompt here", "clip": ["2", 0] } } } -
Edit the
inputsfields in the JSON to change your prompt text (or any other parameter like resolution, seed, etc.). -
Run it via comfy-cli:
comfy launch --background comfy run --workflow my_workflow.json --wait --timeout 180
The command sends your workflow to ComfyUI's /prompt endpoint, monitors execution via WebSocket, and reports progress and output paths when done [5].
If you want to automate prompt changes (e.g., batch-generate with different prompts), you could write a simple Python script that loads the JSON, modifies the relevant text node's inputs.text, saves it, and then calls comfy run.
To reply, just mention @dosu.
Share context across your team and agents. Try Dosu.
@dosu Thank you so much. It would be a good development if the comfy cli could also have the option to edit or flag -- prompt flag --browse the file which we are using. I have to think as comfy supports several important workflows and how to handle. Each individual is different and is important as well as complicated at its own. Thank you again. Maybe if you see any of such, please share in future.
I'm not an expert but editing prompt via CLI may be impossible to implement since workflows may use a several "CLIP Text Encode (Prompt)" nodes or string nodes connected to them. Better stick to modifying JSON file directly