Nodes/ComfyUI-SimpleChat/Prompt JSON Unpack
ComfyUI Node

Prompt JSON Unpack

One JSON from the LLM, everything your sampler needs on the other side

By Moeblack·Created 9 months ago·Updated 7 months ago· 8
Prompt JSON Unpack
    • positive
    • negative
    • width
    • height
    • steps
    • cfg
    • sampler
    • seed
    • notes
    • vars
    • obj
    • sampler_name
    json_text
    strip_code_fencetrue

    This is the node that makes "let the LLM pick the prompt and the sampling parameters" actually work. Prompt JSON Unpack takes one JSON object and splits it into typed ComfyUI outputs - STRING, INT, FLOAT, and even a real SAMPLER - so you can wire an LLM's reply straight into a KSampler without a single convert node in between. The README calls it "recommended," and it is: it's the fixed-schema sibling of the generic JSON Parse, purpose-built for the pack's Anima prompt scheme.

    The contract

    It expects the LLM to output one object with this exact shape:

    {
      "positive": "masterpiece, best quality, 1girl, ...",
      "negative": "lowres, bad anatomy, ...",
      "width": 1024,
      "height": 1024,
      "steps": 40,
      "cfg": 4.5,
      "sampler": "er_sde",
      "seed": -1,
      "notes": "keep the hands simple"
    }
    

    And it hands you, port by port: positive, negative, width, height, steps, seed (INT), cfg (FLOAT), sampler (a SAMPLER object for custom-sampling workflows), sampler_name (the same name as a plain string for display/logging), notes (STRING), plus a vars dict (every field as a Mustache variable like {{anima.positive}} or {{width}}) and obj (the raw parsed object).

    The two smart behaviors

    First, strip_code_fence defaults on, so ```json-wrapped LLM output parses cleanly, and the parser tolerates the classic LLM mistake of trailing commas. Second, if positive is missing, it rebuilds it from the Anima segment fields in tag order - quality_meta_year_safe, count, character, series, artist, style, tags - joined with commas. So a JSON that only carries the eight parts still yields a working positive prompt. Sampler names get normalized too: euler_aeuler_ancestral.

    The workflow

    Chat with the Anima system prompt (in docs/anima_prompt.md) → JSON reply → this node → positive/negative into CLIPTextEncode, width/height into EmptyLatentImage, steps/cfg/sampler into KSampler. The whole sampler side of your graph becomes LLM-driven. The vars output feeds a follow-up Chat so your next prompt can reference {{anima.negative}} and friends. In an XY sweep, feed it the per-cell list from Anima XY Matrix and let ComfyUI's list mapping run it per cell.

    Installing it

    cd ComfyUI/custom_nodes
    git clone https://github.com/Moeblack/ComfyUI-SimpleChat
    

    Restart, or use Manager and search "ComfyUI-SimpleChat". Only dependency: aiohttp.

    Gotchas

    It's fixed-schema - if your JSON uses different keys, fields default (width→1024, steps→40, cfg→4.5, seed→-1, samplerer_sde) and you silently get defaults instead of an error. sampler as an object needs a custom-sampling workflow to consume it; the plain sampler_name string is the safe port for standard KSampler. And if your LLM wraps the JSON in prose instead of a fence, the forgiving parser may still pull the first {...} - but that's a rescue, not a guarantee, so keep your system prompt strict about outputting only JSON.

    CategorySimpleChat/Utils

    Inputs (2)

    NameTypeDefaultDescription
    json_textSTRING
    strip_code_fenceoptBOOLEANtrue

    Outputs (12)

    NameTypeDescription
    positiveSTRING
    negativeSTRING
    widthINT
    heightINT
    stepsINT
    cfgFLOAT
    samplerSAMPLER
    seedINT
    notesSTRING
    varsSIMPLECHAT_VARS
    objSIMPLECHAT_JSON
    sampler_nameSTRING