Stringify JSON [LP]
Stringify JSON [LP] — ComfyUI Node Guide
- json_string
The formatter of this pack's JSON group. You've got JSON that's either ugly (everything mashed on one line, no consistent key order) or came from somewhere that doesn't care about human readability, and you want it clean, indented, and predictable - either to actually read it while debugging a workflow, or to feed it downstream to something that expects a stable, comparable format.
What it does
Under the hood this is the equivalent of Python's json.dumps(parsed, indent=N, sort_keys=bool) - it takes your JSON text, re-serializes it with the indentation and key-ordering you ask for, and gives you back a clean string. It's not adding or removing data, it's reformatting what's there.
That reformatting matters more than it sounds for a couple of practical reasons: if you're diffing JSON output between two runs to check if something changed, sorted keys and consistent indentation make the diff actually mean something instead of just reflecting key order noise. And if you're pasting JSON into a debug text display node while building a workflow, indented output is the difference between "readable in five seconds" and "one unbroken line you have to squint at."
It's part of the JSON group this pack added together - alongside Get JSON Value, Check JSON Key, Get JSON Length, Merge JSON Node - with some of the lineage credited in the README to Comfyui-Simple-Json-Node by Q-Bug4.
Inputs and outputs
json_string(STRING, multiline) - the JSON text to reformat.indent(INT, 0–8, default 4) - spaces per indentation level. Set it to 0 for the most compact valid output that still has line breaks, or push it up if you want more visual separation for deeply nested structures.sort_keys(BOOLEAN, default false) - alphabetize object keys in the output. Off by default, meaning key order from your input is preserved as-is unless you turn this on.
Output: json_string (STRING) - the reformatted result.
Installing it
Through ComfyUI Manager: search "ComfyUI-LevelPixel," listed under "Level Pixel," install and restart ComfyUI. Manual: cd ComfyUI/custom_nodes && git clone https://github.com/LevelPixel/ComfyUI-LevelPixel.git, restart. Nothing to download, no GPU-side dependency - this is a string-formatting node end to end.
Common issues
This node still has to be able to parse your input as valid JSON before it can re-serialize it - a trailing comma, an unquoted key, a stray bracket, and it'll fail on the parse step rather than reformat garbage into something clean. If output looks wrong or the node errors, check your input's actual validity in a JSON linter first; this node fixes formatting, not syntax errors.
If you're expecting sort_keys to reorder a JSON array, it won't - sorting applies to object keys, not array element order, so if your data is a list rather than a dict at the level you're formatting, this setting has nothing to act on there.
And same note as the rest of this pack's JSON group: json_string here is plain text, the STRING type, not the pack's parsed JSON object socket used by Get JSON Value. If you've got a JSON-typed output from elsewhere in your graph and want it formatted, you'll need to convert it to a string first - the two types don't wire together directly.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| json_string | STRING | — | |
| indent | INT | 40–8 | — |
| sort_keys | BOOLEAN | false | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| json_string | STRING | — |