JsonValidate (Yogurt Nodes)
Confirm your JSON is the right shape before you trust it
- data
- is_valid
- error_message
When an LLM or a web service hands you JSON, the two questions are: is it valid and is it the shape I expected? JsonValidate answers both. Feed it any data, tell it what type you expect (and which keys have to be there), and it returns is_valid - a BOOLEAN - plus an error_message string that tells you what was wrong when it isn't.
It's a logic node in the YogurtNodes pack (yogurt7771/ComfyUI-YogurtNodes), and it's the quality gate for the pack's JSON workflow. Think of it as the graph version of a schema check: light, explicit, and it gives you a reason instead of just a thumbs-down.
How it works
Two checks, both simple under the hood. First, check_type (default any) verifies the data is the expected JSON type - object, array, string, number, boolean, null, or any for "don't care". Second, required_keys - a comma-separated list - checks that every listed key is present when the data is an object (it's ignored for arrays and scalars). If both pass, is_valid is True and error_message is empty; if either fails, you get False and a description of which check tripped.
The two outputs are designed to be used together: branch on is_valid, and if you're in the failure branch, log or show error_message so you (or your workflow) know why instead of just knowing it failed.
Inputs that matter
data- anything you want checked.check_type- the expected type. The one beginners skip and then wonder why a list passed their "object" check.required_keys- comma-separated, e.g.id,title,url. Only meaningful for objects, but it's the check that catches "the API changed its schema."
Outputs: is_valid (BOOLEAN) and error_message (STRING).
Install
Pack-wide routine - ComfyUI Manager (search "YogurtNodes") or:
cd ComfyUI/custom_nodes
git clone https://github.com/yogurt7771/ComfyUI-YogurtNodes.git
cd ComfyUI-YogurtNodes
pip install -r requirements.txt
Restart, find it under Yogurt Nodes / Logic. No extra dependencies.
Troubleshooting
- "It's a valid JSON string but validation fails." Validation works on objects, not text. A JSON string is a
stringtype until you Parse it. Stringify's output isn't valid-here - parse first, validate the parsed object. - "It passed but it's clearly wrong."
required_keyschecks presence, not value quality.{"id": null}passes ifidis listed. For "present and non-null", combine with GetPath and a null check. - Type gotchas. JSON
nullis a distinct type - anullcheck only passes for actual nulls. And be careful: in JSON,numberincludes integers and floats; there's no separateintegertype here. - "Why did my whole workflow die?" If you're validating at the input and then not branching on the result, you've built the check but ignored it. Wire
is_validinto a Switch so a bad payload takes a fallback path (or a clear error output) instead of silently failing deeper in the graph.
The workflow worth building: parse → validate with required keys → branch. One node turns "trust me" JSON into "I checked" JSON, and the error_message output means the failure message lands in your workflow where you can act on it, not in a log you'll find an hour later.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| data | * | Data to validate | |
| check_typeopt | COMBO | any | Expected data type |
| required_keysopt | STRING | Required keys for objects (comma-separated) |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| is_valid | BOOLEAN | — |
| error_message | STRING | — |