Simple JSON Parser Node for ComfyUI
A custom node for ComfyUI to parse and extract data from JSON strings.
Features
- Parse JSON strings
- Access specific JSON content using paths
- Output formatted JSON or simple string values
Installation
- Go to your ComfyUI custom nodes directory:
cd ComfyUI/custom_nodes/
- Clone the repository:
git clone git@github.com:Q-Bug4/Comfyui-Simple-Json-Node.git
- Restart ComfyUI or reload custom nodes.
Usage
Find the "Simple JSON Parser" node in the "utils" category of ComfyUI.
Inputs:
json_string
: JSON string (multiline supported)path
: Data path (optional)
Output: Parsed JSON data or specific value
Path Syntax
- Nested objects:
object.nestedObject.property
- Array elements:
array[0]
- Complex structures:
object.array[2].property
Examples
-
Parse JSON:
- Input:
{"name": "John", "age": 30}
- Path: (empty)
- Output: Formatted JSON
- Input:
-
Access property:
- Input:
{"user": {"name": "Alice", "email": "alice@example.com"}}
- Path:
user.email
- Output:
alice@example.com
- Input:
-
Access array:
- Input:
{"items": ["apple", "banana", "cherry"]}
- Path:
items[1]
- Output:
banana
- Input:
Error Handling
ValueError is raised for:
- Invalid JSON string
- Invalid path or key not found
Contributing
Improvements are welcome! Steps:
- Fork the repository
- Create a new branch
- Make changes
- Push to your fork
- Submit a Pull Request
License
MIT License. See LICENSE file for details.