ComfyUI Node

HTTP Convert JSON

Make API JSON readable, or minify it back down for the wire

By wawahuy·Created about a year ago·Updated 11 months ago· 14
HTTP Convert JSON
    • result
    • formatted
    input_data{}
    operationparse
    indent2
    sort_keysfalse
    ensure_asciifalse

    ComfyUI's text fields are ruthless about JSON: paste a minified one-liner into an HTTP node and you can't see what's actually there. HTTP Convert JSON is the pretty-printer and the minifier in one, the node you keep in the corner of every API workflow just to make responses legible - or to shrink a payload down before it goes back out.

    What it does

    One required input, input_data (the JSON text), and one required choice, operation:

    • parse - parse the JSON and hand back both a compact string and a formatted one.
    • stringify - turn a value into a JSON string.
    • format - re-indent JSON with indent spaces (default 2) so you can actually read a response.
    • minify - strip all whitespace into the tightest {"key":"value"} form, useful when an endpoint rejects pretty-printed bodies or you're counting characters.

    The optional inputs give you control over the output: indent (0–8), sort_keys, and ensure_ascii. That last one is worth knowing - it's off by default, which means non-ASCII characters survive as-is instead of becoming \uXXXX escapes.

    Two outputs: result and formatted. For format and minify both outputs are identical; for parse and stringify you get the compact version in result and the indented one in formatted. Wire whichever your downstream wants.

    How it fits

    Typical spot: after an HTTP GET, route content through operation = format and into HTTP Display Result (or just a text preview) so you can eyeball what the API said. Before an HTTP POST, run your body through minify and you've got a clean payload. It also rescues you from having to hand-edit JSON inside a text widget, which is where JSON syntax errors are born.

    Install

    ComfyUI Manager → search "ComfyUI-HTTP" → Install, restart. Manual:

    cd ComfyUI/custom_nodes/
    git clone https://github.com/wawahuy/ComfyUI-HTTP.git
    cd ComfyUI-HTTP
    pip install -r requirements.txt
    

    No models, and this particular node doesn't even need the pack's JSONPath dependency - it's pure standard-library json.

    Where people get burned

    Invalid input doesn't raise - both outputs just carry the error message ("JSON parsing error: ..."). That's actually decent behavior, but it means you can't rely on the node to catch your mistakes for you; the mistake just travels downstream as a string. And don't confuse parse with stringify on first click: if you feed already-formatted JSON into parse, you get a compact result and an indented formatted - if what you wanted was "just leave it alone," pick format.

    CategoryHTTP/JSON

    Inputs (5)

    NameTypeDefaultDescription
    input_dataSTRING{}
    operationCOMBOparse4 options: parse, stringify, format, minify
    indentoptINT20–8
    sort_keysoptBOOLEANfalse
    ensure_asciioptBOOLEANfalse

    Outputs (2)

    NameTypeDescription
    resultSTRING
    formattedSTRING