Nodes/ComfyUI Level Pixel/Convert Any To Text [LP]
ComfyUI Node

Convert Any To Text [LP]

The forgiving stringify-anything node

By LevelPixel·Created 2 years ago·Updated 6 months ago· 31
Convert Any To Text [LP]
  • any_value
  • text
as_jsonfalse

Every other converter in this pack is strict about its input type - IntToString-LP wants an INT, StringToFloat-LP wants a STRING, and each will refuse a connection or error at runtime if you feed it the wrong thing. AnyToText-LP is the opposite philosophy: its input is wildcard-typed (*), so you can wire literally anything into it and get text back, no matter what actually shows up on the wire.

Why the loose typing is the point

Sometimes you don't know or don't care exactly what type is coming down a wire - maybe it's a value from a branch that could be an INT in one path and a FLOAT in another, or you're building a generic debug/display step where you just want to see something readable regardless of type. Reaching for a strict converter in that situation means guessing the type correctly every time, and it breaks the moment you're wrong. AnyToText-LP sidesteps that entirely at the cost of some control over the exact formatting - it's the forgiving option, not the precise one.

The inputs and outputs that matter

  • any_value - wildcard-typed (*), accepts whatever you wire in.
  • as_json - a boolean, default false. Off, you get Python's default string representation of whatever came in. On, it's formatted as JSON instead - which matters for structured values like a list or a dictionary, where JSON gives you predictable, re-parseable formatting rather than Python's str()/repr() style (which uses single quotes and isn't valid JSON on its own).
  • Output - text, a plain STRING.

When to flip as_json on

If you're piping structured data through this node and want the result to be genuinely usable as JSON downstream - say, logging a dict of settings, or producing something another tool can parse back in - turn it on. If you're just eyeballing a value on a Show Text node for debugging, leave it off; Python's default string form is usually more readable for a quick glance.

How to install it

ComfyUI Manager: search "ComfyUI Level Pixel" or ComfyUI-LevelPixel, install, restart - auto-updates via Manager's "Update ALL." Manual:

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

Restart ComfyUI. Pure Python, no models, nothing extra to install.

Common issues & troubleshooting

Turning as_json on throws an error instead of producing text. Whatever you fed into any_value probably isn't JSON-serializable - a raw image tensor, a custom Python object, or something else JSON's encoder doesn't know how to handle. Flip as_json back off; the plain-string path handles arbitrary objects far more gracefully, generally falling back to that object's default text representation instead of failing outright.

The output looks different from what you expected for a list or dict. With as_json off, you'll see Python's native formatting (single-quoted strings, True/False capitalized) rather than JSON's conventions (double-quoted strings, true/false lowercase). If you need the JSON convention specifically - for downstream parsing, or just readability - that's exactly what the toggle is for.

You actually know the type coming in and want strict, predictable formatting. This node's flexibility is also its imprecision - for a known INT or FLOAT where you want guaranteed, specific formatting, the pack's dedicated IntToString-LP or a similar strict converter will serve you better than the general-purpose one here.

CategoryLevelPixel/Conversion

Inputs (2)

NameTypeDefaultDescription
any_value*
as_jsonBOOLEANfalse

Outputs (1)

NameTypeDescription
textSTRING