Skip to main content
Templates are ComfyUI workflows exported as JSON files that can include special placeholders for dynamic values. They enable you to create reusable workflow patterns that can be executed with different parameters.

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:
  1. Before uploading: Edit the exported JSON file to include placeholders
  2. 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
{
  "6": {
    "inputs": {
      "text": "$text(prompt)",
      "negative_prompt": "$text(negative)",
      "steps": "$text(num_steps)"
    }
  }
}
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
{
  "10": {
    "inputs": {
      "image": "$file(input_image)",
      "mask": "$file(mask_image)"
    }
  }
}
File naming requirements:
  • Maximum 255 characters
  • Only alphanumeric characters, hyphens, and underscores allowed
  • No special characters or spaces
All $file() placeholders are required. The workflow execution will fail if files are not provided or don’t meet naming requirements.

$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
{
  "3": {
    "inputs": {
      "seed": "$random()",
      "noise_seed": "$random()"
    }
  }
}
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
{
  "9": {
    "inputs": {
      "filename_prefix": "$timestamp()"
    }
  }
}
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
{
  "6": {
    "inputs": {
      "text": "$text(prompt)",
      "seed": "$random()",
      "steps": 20
    }
  },
  "10": {
    "inputs": {
      "image": "$file(input_image)",
      "filename_prefix": "$timestamp()"
    }
  }
}
When you execute this template, ComfyControl will:
  1. Display a form requesting the prompt text input
  2. Display a file upload field for input_image
  3. Automatically generate a random seed value
  4. 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.
{
  "inputs": {
    "seed": "$random()",
    "filename": "$timestamp()"
  }
}
Partial replacements like "prefix_$random()" or "image_$timestamp().png" will not work. The placeholder must be the complete value.

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
{
  "3": {
    "inputs": {
      "positive": "$text(prompt)",
      "seed": "$random()"
    }
  },
  "6": {
    "inputs": {
      "text": "$text(prompt)",
      "another_seed": "$random()",
      "timestamp": "$timestamp()"
    }
  },
  "9": {
    "inputs": {
      "filename_prefix": "$timestamp()"
    }
  }
}
In this example:
  • 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:
  1. Parses all placeholders in the template
  2. Generates a form with inputs for required placeholders ($text and $file)
  3. Auto-generates values for $random() and $timestamp()
  4. 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
  5. Replaces placeholders with provided or generated values
If validation fails, the workflow creation request will return an error. Ensure all required values are provided and meet the validation requirements.