Creating Templates
Export your workflow from ComfyUI in API format and add it as a template to ComfyControl. You can add placeholders in two ways:- Before uploading: Edit the exported JSON file to include placeholders
- After uploading: Use the web editor to modify the template and add placeholders
Placeholder Types
Templates support six types of placeholders that enable dynamic workflow execution:$text(key) or $text(key, default)
Text input parameter for prompts, strings, and numeric values. Use this for any textual input like prompts, descriptions, or configuration strings. You can also provide integer values such as number of frames or step counts—ComfyUI will handle type casting automatically.
Optionally, you can provide a default value that will be pre-filled in the form when executing the template.
template_text_example.json
All
$text() placeholders are required. Users must provide values when executing the template. If a default value is specified, it will be pre-filled in the form but can be modified by the user.$choice(name, v1, v2, v3, v4)
Multiple choice parameter for selecting from predefined options. Supports 2 to 4 choices. This is useful for selection fields like samplers, schedulers, or other enumerated options.
template_choice_example.json
All
$choice() placeholders are required. The first option (v1) is used as the default value. Users can select from the provided options when executing the template.$file(name)
File upload reference for images and assets. The name parameter becomes the field name in the form request and maps to the uploaded file.
template_file_example.json
- Maximum 255 characters
- Only alphanumeric characters, hyphens, and underscores allowed
- No special characters or spaces
$random()
Generates a 64-bit random integer value. Useful for creating random seeds in KSamplers and other nodes requiring seed values.
template_random_example.json
Each
$random() placeholder is replaced with a unique random value. Multiple placeholders will generate different values. During workflow re-runs, $random() values remain unchanged from the original execution.$timestamp()
Current timestamp in Unix milliseconds (milliseconds since Unix epoch). Ideal for generating unique filenames and tracking execution time.
template_timestamp_example.json
All
$timestamp() placeholders in a single template execution are replaced with the same consistent timestamp value. During workflow re-runs, $timestamp() values remain unchanged from the original execution.Complete Example
Here’s a complete template demonstrating all placeholder types:complete_template_example.json
- Display a form requesting the
prompttext input andnegativetext input (with default value pre-filled) - Display a dropdown selection for
samplerwith the available options - Display a file upload field for
input_image - Automatically generate a random seed value
- Automatically generate a timestamp for the filename
Placeholder Rules
Exact Value Replacement
Placeholders must occupy the entire JSON value for replacement to work. Partial replacements are not supported.Repeated Placeholders
Placeholders with the same name are replaced consistently across the template:$text(key),$choice(name, ...), and$file(name): All occurrences with the same key/name are replaced with the same value$timestamp(): All occurrences receive the same timestamp$random(): Each occurrence receives a unique random value
repeated_placeholders_example.json
- Both
$text(prompt)placeholders receive the same user input - Each
$random()generates a different value - Both
$timestamp()placeholders receive the same timestamp
Executing Templates
When you execute a template, ComfyControl automatically:- Parses all placeholders in the template
- Generates a form with inputs for required placeholders (
$text,$choice, and$file) - Auto-generates values for
$random()and$timestamp() - Validates inputs before creating the workflow:
- Empty values: Not allowed for
$text(),$choice(), and$file()placeholders - File names: Must be 255 characters or less and contain only alphanumeric characters, hyphens, or underscores
- Missing values: Any missing required placeholder will fail the request
- Empty values: Not allowed for
- Replaces placeholders with provided or generated values
When you re-run a workflow, system-generated placeholders like
$random() and $timestamp() retain their original values from the initial execution, ensuring consistency across re-runs.