XAV JSON to Primitives
The only node that turns an opaque JSON ref back into real values
- int_val
- float_val
- bool_val
- str_val
Every other node in this pack moves opaque references around - the json_ref outputs are just UUID handles into an in-memory cache, not data you can use. This is the one that turns the handle back into something ComfyUI's normal nodes understand: an integer, a float, a boolean, a string. Loaded a config and want its value in a text encoder, a seed slot, or a filename token? This is your exit ramp.
One input: json_ref. Four outputs, all derived from the same underlying object: int_val, float_val, bool_val, str_val. The casting is blunt, straight from the source: int(obj) and float(obj) with a fallback to 0 / 0.0 when conversion fails; a bool that handles None → False, treats the strings "true", "1", "yes" (case-insensitive) as True, and otherwise just calls bool(obj); and str_val which is plain str(obj).
What that actually produces:
- A ref pointing at the number 5 →
5,5.0,True,"5". - A ref pointing at the string
"42"→42,42.0, butFalsefor the bool - "42" isn't in the true-list. Cute, and exactly the kind of thing that confuses people. - A ref pointing at a nested object →
0,0.0,True, and astr_valthat looks like{'a': 1}.
That last one is the trap worth remembering: str() of a dict gives you Python's repr, not valid JSON. If you need actual JSON text out of an object, use XAV Save JSON to File instead - this node is for leaves, not trees.
Wire whichever output you need. The classic moves: str_val into a CLIP Text Encode or any string input, int_val or float_val into a seed or a size slot, bool_val into a switch or toggle. The outputs that don't fit what's stored just come back 0 / 0.0 / False with no error - convenient, and also a great way to silently feed a bad number downstream. If a seed suddenly reads 0, the ref was probably pointing at nothing, or you asked for an int from a value that isn't one.
This node is also the pack's answer to a complaint you'll hit the moment you start editing JSON: XAV Set JSON Value stores everything you type as a string. Set a key to 5 and the object holds "5". Convert it here and the wire going forward carries a real integer 5 - the stored value stays a string, but the output is typed. That alone is worth wiring this node in before anything that cares about numbers.
Install is painless because this pack is pure Python stdlib - zero dependencies, nothing to download. ComfyUI Manager → Install Custom Nodes → search "ComfyUI XAV JSON Nodes", or:
cd ComfyUI/custom_nodes
git clone https://github.com/XAV-Games/ComfyUI-XAVJsonNodes
Then restart ComfyUI. All seven nodes live under Add Node → XAV/json.
Inputs (1)
| Name | Type | Default | Description |
|---|---|---|---|
| json_ref | STRING | — |
Outputs (4)
| Name | Type | Description |
|---|---|---|
| int_val | INT | — |
| float_val | FLOAT | — |
| bool_val | BOOLEAN | — |
| str_val | STRING | — |