2026-01-22 17:10:25 +01:00
2026-01-22 17:10:25 +01:00
2026-01-22 17:02:47 +01:00
2026-01-22 17:10:25 +01:00
2026-01-22 17:02:47 +01:00
2026-01-10 19:21:18 +01:00
2026-01-22 17:02:47 +01:00
2026-01-22 16:52:19 +01:00

A1111 Prompt Node

A custom ComfyUI node that implements A1111-style prompt handling with proper isolation, emphasis math, scheduling, and alternation.

Installation

Requires lark for full nested syntax support:

pip install lark

Features

Positive prompt node

image

Negative prompt node

image

Full setup with optional TIPO support

image

Core Features

  • Hard Chunking (The Sandbox): Tokens split into 75-token chunks with padding, preventing concept bleeding
  • Direct Scaling (Anti-Burn): Uses z * weight instead of Comfy's interpolation, avoiding artifacts at high weights
  • BREAK Support: Fully isolated context windows - each BREAK segment is tokenized separately
  • Emphasis: (text:1.2), (text), [text]
  • TIPO support: TIPO prompt output can connect directly into the node, and it will show the generated prompt when the node receives it. Should use my fork to preserve weighting emphasis in the a1111 snytax.

Token Counter

The node displays a live token count in the header, showing tokens per 77-token sequence:

45/75 | 32/75
  • Each number shows tokens in that sequence (max 75 usable per sequence)
  • BREAK creates new sequences: dog, cat BREAK bird → 6/75 | 1/75
  • Updates in real-time as you type
  • Uses ComfyUI's native tokenizer for accurate counts
  • Clickable for breakdown and input ids

Warning Colors:

  • Gray (default): Normal prompt length
  • Yellow/Orange: 300+ total tokens (4+ chunks) - getting long
  • Red: 450+ total tokens (6+ chunks) - may impact quality/memory

Boundary Markers:

  • Orange vertical bars appear in the text where 75-token chunk boundaries fall
  • Blue vertical bars mark BREAK positions
  • Markers align with word boundaries and update in real-time

Tag Autocomplete

The node includes A1111-style tag autocomplete functionality:

  • Trigger: Start typing any tag (2+ characters)
  • Database: Uses Danbooru/e621 tag databases (~140k tags)
  • Search: Matches tag names and aliases
  • Navigation: Use ↑/↓ arrows, Tab/Enter to select, Escape to close
  • Color coding: Tags are colored by type (general, artist, character, etc.)
  • Post counts: Shows tag popularity for better selection
  • Frequency sorting: Your frequently used tags appear first with a ★ indicator
  • Theme support: Automatically adapts to ComfyUI's theme (dark/light/custom)

Features:

  • Alias support: Type sole_female → suggests 1girl
  • Smart insertion: Automatically adds commas and handles spacing
  • Parenthesis escaping: name_(artist) → name_\(artist\)
  • Real-time search with 100ms debouncing
  • Usage tracking: Tags you use often are prioritized in results
  • Quality tags: Automatically includes extra-quality-tags.csv for common quality/style tags
  • Theme-aware: Respects your ComfyUI color scheme

Available tag databases:

  • danbooru.csv - Main Danbooru database (~140k tags)
  • e621.csv - E621 database (furry-focused)
  • extra-quality-tags.csv - Quality and style tags (auto-loaded)
  • Custom CSV files can be added to data/tags/

Frequency Management: Open browser console and use:

  • window.A1111Autocomplete.getStats() - View your most used tags
  • window.A1111Autocomplete.resetFrequency() - Clear usage data
  • window.A1111Autocomplete.exportFrequency() - Backup your data

Scheduling

Syntax Meaning
[cat:dog:0.5] Switch from "cat" to "dog" at 50%
[cat:dog:10] Switch at step 10 (requires steps input)
[glasses:0.5] Add "glasses" at 50%
[glasses:10] Add at step 10
[hat::0.7] Remove "hat" at 70%
[hat::15] Remove at step 15

Nested syntax supported:

[honovy, exsys:chen bin, [as109|fkey], [sweetonedollar:11]:0.4]

Alternation

Syntax Meaning
[white|black] Switches per-step (step 1=white, step 2=black...)
[A|B|C] Cycles through options each step
[A|] Alternates between A and nothing

Scheduled Alternation (Extension)

Control when alternation starts or stops:

Syntax Meaning
[as109|fkey::0.6] Alternate until 60%, then nothing
[as109|fkey:0.4] Nothing until 40%, then start alternating
[as109|fkey::15] Alternate until step 15, then nothing

Combining with scheduling to lock to a value:

[as109|fkey::0.6][:as109:0.6]

This alternates until 60%, then switches to just "as109".

Model Support

  • SDXL: Dual CLIP (clip_l + clip_g) with independent weight scaling
  • SD1.5: Full support

Usage

This pack provides two nodes:

Node Use Case
A1111 Style Prompt Positive prompt (supports alternation/scheduling)
A1111 Style Prompt (Negative) Negative prompt (no alternation support)

A1111 Style Prompt (Positive)

Inputs

Input Type Required Description
clip CLIP Yes The CLIP model
text STRING Yes Prompt with A1111 syntax
model MODEL No Required for alternation/step-based conditioning
steps INT No Total sampling steps (default: 20)
normalization BOOL No Enable EmphasisOriginalNoNorm
debug BOOL No Show detailed schedule information

Outputs

Output Type Description
conditioning CONDITIONING The encoded conditioning
model MODEL Model with step wrapper

A1111 Style Prompt (Negative)

Inputs

Same as positive, but without MODEL input.

Outputs

Output Type Description
conditioning CONDITIONING The encoded conditioning

Note: If scheduling/alternation syntax is used in the negative node, it will use the first step's prompt only and log an informational message.

Workflow

For alternation and per-step scheduling to work correctly, you must connect the MODEL input on the positive node:

        ┌─────────────────────────────┐
MODEL ──┤  [A1111 Style Prompt]       ├──► MODEL ──────────► Sampler
CLIP  ──┤                             ├──► CONDITIONING ──► (positive)
        └─────────────────────────────┘

        ┌─────────────────────────────┐
CLIP  ──┤  [A1111 Style Prompt (Neg)] ├──► CONDITIONING ──► (negative)
        └─────────────────────────────┘

Without MODEL connected, only static prompts work (no alternation).


Examples

# Basic emphasis
a (beautiful:1.3) landscape

# BREAK for isolation
artist name BREAK character name, wearing a hat

# Step-based scheduling (with steps=28)
[mountains:ocean:14] at sunset

# Alternation (requires MODEL connected)
1girl, [as109|fkey], detailed

# Add element at specific step
1girl, [sweetonedollar:11], high quality

# Nested scheduling with alternation
1girl, [honovy:chen bin, [as109|fkey]:0.4]

# Scheduled alternation - stop at 60%
1girl, [as109|fkey::0.6], detailed

# Combined
(epic:1.2) [forest:city:0.3] BREAK detailed background

Debug Mode

Enable the debug input to see detailed information:

[A1111 Prompt] Unique prompts: 4 (will encode each once)
[A1111 Prompt] Step transitions: 27 across 28 steps
[A1111 Prompt] Alternation pattern sample:
  Step 0: 1girl, chen bin, yoneyama mai, as109, , agm...
  Step 1: 1girl, chen bin, yoneyama mai, fkey, , agm...
  Step 2: 1girl, chen bin, yoneyama mai, as109, , agm...

Technical Notes

How Scheduling Works

The node generates the correct prompt text for each step, matching A1111's behavior:

  • All unique prompts are encoded once (efficient caching)
  • Per-step embeddings are stored and swapped via model wrapper
  • Sigma-based step detection maps the sampling progress to steps

Known Limitations

  1. Alternation is positive-only: Only the main node (with MODEL input) supports alternation. The negative node will use the first step's prompt if scheduling syntax is present.

  2. Visual parity: While the prompt schedule matches A1111 exactly (the same prompt text at each step), the visual effect may differ due to architectural differences:

    • A1111 applies conditioning at the CFGDenoiser level (before model call)
    • This node applies conditioning via model wrapper (during model call)

Use the scheduled alternation syntax ([a|b::0.6]) if you need to control exactly when alternation stops.


Performance

  • Efficient encoding: Unique prompts are encoded only once and cached
  • [A|B] with 28 steps only encodes 2 prompts, not 28
  • All embeddings are padded to the same length for efficient swapping
  • BREAK segments are batched together for efficient processing
S
Description
No description provided
Readme MIT
17 MiB
Languages
Python 69.5%
JavaScript 30.5%