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 four types of placeholders that enable dynamic workflow execution:$text(key)
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.
template_text_example.json
All
$text() placeholders are required. Users must provide values 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.$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.Complete Example
Here’s a complete template demonstrating all placeholder types:complete_template_example.json
- Display a form requesting the
prompttext input - 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)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 (
$textand$file) - Auto-generates values for
$random()and$timestamp() - Validates inputs before creating the workflow:
- Empty values: Not allowed for
$text()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