JSON File Loader (Soze)
Read a JSON file three ways at once
- Json_Contents
- Formatted_Json_Contents
- Minified_Json_Contents
- Filename_Path
- Filename
- Filename_No_Ext
A basic file-read node that saves you a couple of follow-up nodes: point it at a .json file and it hands back the content raw, pretty-printed, and minified all at once, plus the filename pieces already split out - so you're not chaining a separate "get filename from path" node just to log which file you loaded.
How it works
json_filepath in, and out come three variants of the same content: the raw text as it sat in the file, a formatted version with consistent indentation (handy for a debug preview), and a minified version with the whitespace stripped (handy if you're re-embedding it somewhere size-conscious, like an API call). Alongside that it gives you the full path, just the filename, and the filename with the extension stripped off.
This node reads text and re-serializes it - it doesn't pull individual values out. For that, this pack's JSON Value Parser is the node you chain right after this one: load the file here, then pull specific keys with that.
The inputs and outputs that matter
One required input: json_filepath (STRING).
Six outputs: Json_Contents (raw), Formatted_Json_Contents (pretty-printed), Minified_Json_Contents (compact), Filename_Path, Filename, and Filename_No_Ext.
How to install it
ComfyUI Manager → search "ComfyUI_Soze" → install → restart. Manual:
cd ComfyUI/custom_nodes
git clone https://github.com/SozeInc/ComfyUI_Soze.git
pip install -r ComfyUI_Soze/requirements.txt
then restart. No models, no external service - just file I/O and JSON parsing.
Common issues & troubleshooting
Same absolute-vs-relative path resolution issue that shows up across every file-based node in this pack: a relative path resolves against wherever the ComfyUI process was started, not against your workflow's own location. If a path that "should" be right throws file-not-found, try the full absolute path before assuming the node is broken.
Malformed JSON isn't handled gracefully by most simple loader nodes, and the schema here doesn't document a fallback - treat a parse failure as a hard stop on the run rather than expecting an empty-but-valid result. If you're building the JSON file with another tool or script upstream, validate it there first (any JSON linter will do) rather than debugging it after it's already failed inside ComfyUI.
If you only need one field out of a larger file rather than the whole thing, this node still isn't the wrong starting point - load it here to get Json_Contents, then hand that string straight to JSON Value Parser to pull out the specific key you actually need.
It's also worth knowing why you'd reach for the formatted vs. minified variant specifically rather than always using the raw contents. A JSON file saved by a hand-editing pass or a pretty-printing tool already carries whitespace and indentation baked in, so Json_Contents is only as readable as however the source file happened to be formatted - Formatted_Json_Contents normalizes that for a debug preview regardless of how the file was originally saved, and Minified_Json_Contents is the one you actually want if you're re-embedding the object somewhere with a size or line-length constraint, like a single line in a .env value or an API parameter field.
Inputs (1)
| Name | Type | Default | Description |
|---|---|---|---|
| json_filepath | STRING | — |
Outputs (6)
| Name | Type | Description |
|---|---|---|
| Json_Contents | STRING | — |
| Formatted_Json_Contents | STRING | — |
| Minified_Json_Contents | STRING | — |
| Filename_Path | STRING | — |
| Filename | STRING | — |
| Filename_No_Ext | STRING | — |