ComfyUI Node

Parse JSON5

The parser that tolerates everything LLMs and humans write

By Duanyll·Created about a year ago·Updated 4 months ago· 2
Parse JSON5
    • *
    json_string

    Strict JSON is a pain in the ass to produce by hand or by model: every quote must be double, no trailing commas, no comments, every key quoted. JSON5 is the superset that forgives all of it - single quotes, unquoted keys, trailing commas, // and /* */ comments, even hex numbers. Parse JSON5 runs any string through the json5 parser and hands you the resulting object as a wildcard output. If you've ever tried to feed an LLM's half-formed JSON into a strict parser and watched it die, this is your insurance policy.

    Why JSON5 instead of the built-in JSON?

    ComfyUI's own Parse Raw JSON node uses strict parsing. It's fine for clean input and it's the right tool when you want a loud failure. But two sources of JSON are notoriously dirty: large language models (they drift, they add commentary, they produce trailing commas and stray backticks) and humans pasting configs by hand. JSON5 absorbs all the common dirty patterns silently. That's exactly why this pack ships both - the strict node for clean data, this one for "it came out of an LLM / a user."

    So the real use case: paste a string in (multiline input), get a dict or list out the wildcard socket, then query it with the pack's JSON Path nodes or wire it straight into a node that wants structured data.

    Inputs and outputs

    • json_string - multiline STRING containing JSON5 (or plain JSON, which is a subset of JSON5).

    Output: a single wildcard value - a dict, list, string, number, whatever the text contained. Note there's no error-handling switch; genuinely unparseable input raises and stops the run. If you're parsing LLM output and want resilience and the ability to inspect failures, pair this with the pack's LLM-output parser (ParseLlmJsonOutput) which extracts the last JSON block from messy text first.

    Installing it

    It's in Duanyll Nodepack. ComfyUI Manager → search "Duanyll Nodepack" → install → restart, or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/Duanyll/duanyll_nodepack
    

    The json5 library is in the pack's requirements, so it comes along on install. The node lives under duanyll/data.

    My take: if you know your input is clean JSON, the strict parser is the more honest choice - it fails loudly instead of silently accepting. JSON5's tolerance is a feature when the input is dirty, and a mild risk when it isn't. Use it where the data is out of your control (LLMs, files, users) and you'll save yourself a stack of "why did this break" moments.

    Categoryduanyll/data

    Inputs (1)

    NameTypeDefaultDescription
    json_stringSTRING

    Outputs (1)

    NameTypeDescription
    **