Preview Text
The Show-Text Clone That Pretty-Prints Your JSON
- text
You've wired a text pipeline together and now you need to see what it's producing. The pack's Show Text node already does the basic version of this. Preview Text is the sibling that adds one genuinely useful trick: a format_json toggle that pretty-prints structured text so you can actually read it.
If your text is plain prose, this node and Show Text are interchangeable - pick whichever you like the look of. If your text is JSON (and with an LLM node in the graph, it often is), the formatting toggle is the reason to reach for this one.
How it works
The Python side is a standard output node: it takes text, and reports it to the UI while also passing it through as a STRING output:
def preview(self, text, format_json=False):
preview_text = str(text or "")
return {"ui": {"text": (preview_text,)}, "result": (preview_text,)}
The cleverness lives in the frontend (web/js/text/preview.js). When format_json is on, it parses the text as JSON and re-serializes it with two-space indentation. It even handles the two failure modes that make raw LLM output painful:
- It strips surrounding markdown fences (
```...```) before parsing - the classic shape of an LLM that wraps its answer in a code block. - If the parsed value is itself a JSON string (yes, models do this), it parses the nested string too and pretty-prints that.
If parsing fails for any reason, it just shows the raw text rather than crashing - degraded gracefully, which is the right behavior for a debug node.
Inputs and outputs
- text (
STRING) - what you want to inspect. It'sforceInput, so it wants a wire. - format_json - a boolean toggle, default off. Flip it on for structured output.
- text (output) - the same string passes through, so you can tap the node into a pipeline without breaking it. Unlike Show Text (which outputs a list), this one emits a single plain
STRING.
Where it fits
The natural partner is the pack's OpenAI Compatible LLM node, which often returns JSON, markdown, or a fence-wrapped blob. Drop Preview Text on the LLM output, flip format_json, and suddenly the node's answer is readable - and the cleaned, unwrapped version flows downstream to whatever consumes it. It also re-runs on every execution (IS_CHANGED returns NaN), so the preview is always fresh rather than cached.
Install
It's one of eleven nodes in geocine-comfyui - one install, all nodes:
- ComfyUI Manager → search geocine-comfyui → install → restart
- or Comfy CLI:
comfy node install geocine-comfyui - or manually:
cd ComfyUI/custom_nodes
git clone https://github.com/geocine/geocine-comfyui
then restart ComfyUI. No model downloads; the pack's only pip dependency is openai, for the LLM node.
Gotchas
It's a preview, not a transformer. The pretty-printed version you see in the node is cosmetic - the result output is the raw text as it came in, not the formatted version. If you need the cleaned text (fence stripped, JSON parsed) to feed a downstream node, this won't do that for you; use a Text Replace or a JSON node for the actual transformation. format_json with plain prose is harmless - parsing fails, it shows the raw text, life goes on.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| text | STRING | — | |
| format_json | BOOLEAN | false | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| text | STRING | — |