Nodes/ComfyUI-SimpleChat/Anima XY Matrix (JSON List)
ComfyUI Node

Anima XY Matrix (JSON List)

Turn one Anima JSON prompt into a whole artist × background sweep

By Moeblack·Created 9 months ago·Updated 7 months ago· 8
Anima XY Matrix (JSON List)
    • json_text
    • columns
    • x_labels
    • y_labels
    json_text
    strip_code_fencetrue
    x_fieldartist
    x_list@artist1 @artist2
    y_fieldenvironment
    y_listsunset street night city
    include_environment_in_positivetrue
    auto_y_from_x_when_emptytrue
    same_field_behaviorcombine
    pair_joinnewline
    custom_join\n
    diagonal_singletrue
    matrix_modefull

    The whole point of asking an LLM for a prompt is that it gives you one JSON with every field pre-filled. The whole pain is that you want to test variations of it - this artist against that artist, this background against that one - and you don't want to re-prompt the LLM sixty times to get sixty variants. Anima XY Matrix (JSON List) is the node that does that expansion for you: one base JSON in, a cross-product list of JSONs out, each cell swapping in one value from your X list and one from your Y list.

    It's built around the Anima prompt scheme (Circlestone's 2B anime model), where a prompt is eight named parts - artist, style, environment, character, series, tags, quality, count, neg - but the mechanism is generic enough that any structured JSON with named string fields works.

    How it works

    You give it the base json_text, pick an x_field (say artist) with an x_list (one per line, @artist1, @artist2...), and a y_field (say environment) with a y_list. It produces the row-major cross product: every Y against every X, so y0×x0, y0×x1, ..., exactly matching how XY Plot (Labels) lays out a grid. Each cell is the original JSON with the chosen fields swapped.

    The json_text output is a list - the node sets OUTPUT_IS_LIST, so ComfyUI's list mapping fans it out and runs your sampler once per cell. It also hands you columns (just len(x_list)) plus x_labels and y_labels, which are meant to be fed straight into SimpleChatXYPlot so the grid you generate gets labelled for free.

    Options worth knowing

    • auto_y_from_x_when_empty - if y_list is empty it reuses x_list, so an artist × artist matrix is a zero-extra-typing job.
    • same_field_behavior - when X and Y are the same field, override (cell keeps Y's value) vs combine (both tags joined). Combine is the default and usually what you want for tags.
    • pair_join / custom_join - how the two values get joined in the cell: newline, comma, space, or your own separator.
    • diagonal_single - on the diagonal where X==Y, use the single value instead of doubling it. Keep it on.
    • matrix_mode - full, upper_triangle, or diagonal_only. For artist × artist you often only want the upper triangle, which is also what XY Plot knows how to draw with a gray-masked half.

    Downstream chain

    json_text (list) → Prompt JSON Unpack → typed positive/negative/params → your KSampler → batch of images → XY Plot (Labels), with x_labels/y_labels from this node. That whole loop is the pack's flagship workflow and it works because this node produces both the prompts and the labels in one pass.

    Installing and gotchas

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

    Restart, or use Manager and search "ComfyUI-SimpleChat". Only dep is aiohttp.

    Two real friction points. First, the base JSON is parsed with a forgiving parser that strips ```json fences, deletes line comments (// and #), and even repairs missing commas between top-level keys - so it tolerates hand-edited slop, but feed it genuinely broken JSON and the error message is in Chinese. Second, include_environment_in_positive (default on) decides whether environment is baked into the assembled positive prompt. If you're swapping environments in an XY test and you consume positive downstream, leave it on so each cell actually reflects its Y value; turn it off when you want environment to stay out of positive and apply only through whatever consumes the JSON directly. Either way, environment itself is still set in every cell's JSON.

    CategorySimpleChat/Utils

    Inputs (13)

    NameTypeDefaultDescription
    json_textSTRING
    strip_code_fenceBOOLEANtrue
    x_fieldCOMBOartist9 options: artist, style, environment, character, series, tags, +3
    x_listSTRING@artist1 @artist2
    y_fieldCOMBOenvironment9 options: artist, style, environment, character, series, tags, +3
    y_listSTRINGsunset street night city
    include_environment_in_positiveBOOLEANtrue
    auto_y_from_x_when_emptyBOOLEANtrueIf y_list is empty, reuse x_list (useful for artist x artist matrix).
    same_field_behaviorCOMBOcombineWhen x_field == y_field (e.g. artist), choose overwrite or combine.
    pair_joinCOMBOnewline4 options: newline, comma, space, custom
    custom_joinSTRING\nUsed when pair_join=custom. Use \n for newline.
    diagonal_singleBOOLEANtrueWhen X==Y, use single value on diagonal (recommended).
    matrix_modeCOMBOfullWhen x_field==y_field (e.g. artist x artist), choose full matrix or run fewer cells.

    Outputs (4)

    NameTypeDescription
    json_textSTRING
    columnsINT
    x_labelsSTRING
    y_labelsSTRING