ComfyUI Node

JSON to Text

Flatten structured data into a string an LLM can read

By heshengtao·Created 2 years ago·Updated 7 days ago· 2,321
JSON to Text
  • JSON
  • text

LLM prompt inputs want text, not native data structures. Plenty of nodes in this pack - the KG toolkit tools, json_iterator - pass JSON-shaped data around the graph, and at some point you need to turn that into a plain string before an LLM node can actually read it. json2text is that conversion step: one small, boring, necessary node.

How it works

It takes whatever JSON-shaped value is wired into it and serializes it down to a single STRING, suitable for dropping straight into an LLM's prompt or context.

The inputs and outputs that matter

  • JSON - a wildcard-typed input, meaning it'll accept whatever upstream node is producing structured data, whether that's a literal object, an array, or output from one of this pack's own JSON-handling nodes.

Output: text (STRING) - the flattened result. Wire it into an LLM node's prompt input, into get_string-adjacent plumbing, or anywhere else in the graph that expects plain text rather than structured data.

How to install it

Via ComfyUI Manager: search comfyui_LLM_party, install, restart. Manually:

cd ComfyUI/custom_nodes
git clone https://github.com/heshengtao/comfyui_LLM_party.git

Then pip install -r requirements.txt from inside the pack folder using ComfyUI's own Python, and restart. Nothing extra needed for this node - no models, no keys, pure local text conversion.

Common issues & troubleshooting

Output looks like a wall of text instead of something readable. That's the nature of flattening structured data - a deeply nested JSON object turns into a correspondingly dense string. If you're feeding this into an LLM's context and the model seems to be missing pieces of it, consider whether the source data actually needs to be that nested, or whether a simpler structure upstream would produce a cleaner string here.

Nothing comes through at all. Because JSON is a wildcard input, a disconnected or empty upstream node will pass that emptiness straight along - check what's actually feeding into this node before assuming the conversion itself is broken.

You need the reverse - text back into structured data. This node only goes one direction, JSON to text. If you need an LLM's freeform text output turned back into something structured, that's a different job (typically prompting the LLM to emit valid JSON directly, and parsing that downstream) - not something this converter does for you.

Where this fits in a bigger loop. The pack's own iterator nodes (json_iterator) and knowledge-base tools (the KG toolkit nodes) all move JSON-shaped data around the graph natively, because that's the format that's easiest to slice, filter, and pass between them. json2text is the one spot where that data crosses over into something an LLM can actually consume as a prompt. If you're building a loop - pull an item, feed it to the LLM, log the result - this is usually the node sitting right before the LLM call, doing the last bit of translation between "data the graph understands" and "text the model understands."

Category大模型派对(llm_party)/转换器(converter)

Inputs (1)

NameTypeDefaultDescription
JSON*

Outputs (1)

NameTypeDescription
textSTRING