Nodes/mircudx custom nodes/CC Kling Plan Parser
ComfyUI Node

CC Kling Plan Parser

Turning one big LLM JSON dump into per-segment Kling prompts

By mircudx·Created 6 months ago·Updated 6 months ago· 0
CC Kling Plan Parser
    • kling_prompt_for_node
    • kling_prompt
    • negative_prompt
    • segment_script
    • location
    • estimated_seconds
    • segment_count
    • debug_json
    llm_json_text
    segment_index1
    fallback_negativeblur, low quality, distort, flicker, warping, jitter, morphing, watermark, subtitles, text overlay, logo, extra limbs, deformed hands, melted face
    include_negative_in_prompttrue

    The whole Auto-Card-Generator pipeline leans on an LLM to plan Kling prompts, but an LLM hands back one giant JSON blob - and Kling wants one prompt per segment, one clip at a time. CC Kling Plan Parser is the bridge: it takes that blob, pulls out the segment you're working on right now, and hands you a ready-to-paste Kling prompt. Nothing here calls an API. It's pure parsing, which means it's the cheapest node in the pack and the one you'll blame first when the output looks wrong.

    How it works

    Feed it llm_json_text - wire it to output_text from the CC OpenAI Responses node. It tries json.loads first, and if the model wrapped the JSON in prose (they do), it snags the {...} block out of the middle and parses that. Then segment_index picks which entry from the segments array you want, and it pulls that segment's kling_prompt, negative_prompt, script_chunk, and location.

    The one thing to understand is include_negative_in_prompt. On by default, it glues the negative prompt onto the end of your Kling prompt as an Exclude: line, so the Kling node gets one self-contained string. Turn it off if your Kling node has its own negative-prompt input and you want the two kept separate.

    The inputs and outputs that matter

    • llm_json_text - the LLM's response. The one wire that matters.
    • segment_index - which segment you're extracting. The bundled workflows run six of these parsers in a row, one per segment, each hardcoded to a different index.
    • fallback_negative - the negative used if the model didn't return one. The default is the pack's standard Kling negative (blur, low quality, watermark, extra limbs, etc.), and it's a good starting point.

    Outputs: kling_prompt_for_node is the one you wire into your Kling API node - it's the raw prompt plus the Exclude: tail. kling_prompt is the clean prompt, negative_prompt is the negative on its own, segment_script is the voiceover text that segment covers, and location is where the model said the scene happens. segment_count tells you how many segments the whole plan has, which is what drives the segment gates' auto-skip logic.

    Where it burns people

    debug_json is your friend, because the parser has a fallback ladder. If the LLM returns valid JSON with a segments array, great. If it returns a single prompt with no array, you get segment_count = 1. And if the JSON parse fails entirely - say, the model decided to be chatty - it falls back to treating the whole response as one plain-text prompt and reports parse_mode: "fallback_plaintext". That's the mode to look for: it means the LLM ignored its schema hint and you're about to feed Kling a wall of prose. Check debug_json on a Preview node before you burn a generation on it.

    Also note the clamp: segment_index above the actual segment count silently wraps to the last segment instead of erroring. If segment 4 keeps showing segment 3's script, this is why - the plan only has three segments.

    Installing it

    This node ships in the Auto-Card-Generator pack by mircudx - a small MIT-licensed bundle of script-to-Kling pipeline nodes with zero pip dependencies and no model downloads (the LLM and video generation both run through APIs you bring keys for). Two ways in: ComfyUI Manager → Install Custom Nodes → search "Auto-Card-Generator", or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/mircudx/Auto-Card-Generator
    

    Restart ComfyUI and it shows up under "Card Creator/LLM". If you import one of the bundled workflows and get missing-node errors, use the *_local_safe_compat.json variant - it's trimmed for bare local installs. The reference workflows also expect a separate Kling custom-node pack (KlingStartEndFrameNode) to be installed; this pack provides the parsing logic around it, not the Kling API calls themselves.

    CategoryCard Creator/LLM

    Inputs (4)

    NameTypeDefaultDescription
    llm_json_textSTRING
    segment_indexINT11–64
    fallback_negativeSTRINGblur, low quality, distort, flicker, warping, jitter, morphing, watermark, subtitles, text overlay, logo, extra limbs, deformed hands, melted face
    include_negative_in_promptBOOLEANtrue

    Outputs (8)

    NameTypeDescription
    kling_prompt_for_nodeSTRING
    kling_promptSTRING
    negative_promptSTRING
    segment_scriptSTRING
    locationSTRING
    estimated_secondsFLOAT
    segment_countINT
    debug_jsonSTRING