Small set of utility nodes for working with JSON in ComfyUI: repair malformed JSON text, extract values with a simple path syntax, and serialize values back to text.
Category in ComfyUI: utils/json.
- Copy this folder to
ComfyUI/custom_nodes/ComfyUI-JSONand restart ComfyUI.
- Display name:
JSON Repair - Purpose: Repair and parse malformed JSON text. Optionally merge two inputs. Outputs a dict and a list (list-mappable).
- Inputs
json_string(STRING, required): Raw text that likely contains JSON. The node extracts the first balanced object{...}or array[...]from the text. It also strips common code fences (json ...).json_string2(STRING, optional): Second JSON text to merge. Dicts are merged into the object output; arrays are extended into the list output; primitives are appended to the list.
- Outputs
JSON(DICT): Merged object result (empty if no objects were provided).JSON Array(LIST, list-mapped): Merged array result. Emits[None]when empty to avoid ComfyUI list-mapping issues with empty lists.
- How it parses
- Tries strict
json.loads. - Falls back to Python
ast.literal_evaland normalizes to JSON-compatible types. - If available, uses the optional
json_repairlibrary. - If all fail, returns the original text (which will then be treated as a primitive and placed into the list output).
- Tries strict
- Tips
- If your API/tool returns text with extra commentary or code blocks, feed it here first to get clean JSON.
- Display name:
JSON Property Extractor - Purpose: Extract a value from a JSON object (dict) using a simple JS-like path syntax.
- Inputs
json(DICT, required): Parsed JSON object (dict). If you have text, parse it first (e.g., withJSON Repair).property_path(STRING, optional): Path like.a[2].bora.b[0]. Leave empty to return the whole object.
- Outputs
value(*): Extracted value, type preserved (dict/list/string/number/bool/null).value_type(STRING): Friendly type name (e.g.,string,int,dict).key(STRING): Last accessed key or index as a string.
- Path syntax
- Dot for identifiers:
foo.bar - Brackets for indexes:
[0],[-1] - Brackets with quotes for keys (supports dots/spaces):
["a.b"],['key with spaces'] - Whitespace in the path is ignored
- Dot for identifiers:
- Display name:
JSON ➜ String - Purpose: Convert any JSON-compatible value to a JSON string.
- Inputs
-
json(*, required): Any JSON-compatible value (object, array, string, number, boolean, null). Non-serializable objects are serialized viastr(...)as a fallback.pretty(BOOLEAN, default True): Indent with 2 spaces.ensure_ascii(BOOLEAN, default False): Escape non-ASCII characters when True.parse_string_input(BOOLEAN, optional, default False): If the input is a string, try parsing it as JSON before serializing.
ignore_errors(BOOLEAN, optional, default False): On error, log and return{}instead of raising.
- Outputs
json_string(STRING): The JSON text.
- Clean and parse, then extract a field
JSON Repair→JSON Property Extractorwith path like.items[0].name.
- Serialize for logging or saving
- Upstream value →
JSON ➜ String(enable Pretty for readability).
- Upstream value →
- If
JSON Property Extractorerrors that input is not a dict, ensure you parsed text first (viaJSON Repair). - If list-mapping on the array output of
JSON Repairbehaves oddly with empty inputs, note it emits[None]intentionally to avoid ComfyUI slicing errors.
— Inspired by the style of documentation in ComfyUI community repos.