Nodes/honda-nodes/πŸ“‘ JSON Delete Key
ComfyUI Node

πŸ“‘ JSON Delete Key

Surgery on a metadata blob, with jq underneath

By AvarayΒ·Created 14 days agoΒ·Updated 12 days agoΒ· 0
πŸ“‘ JSON Delete Key
    • Result
    β—„json_data{}β–Ί
    β—„key_path.key_to_deleteβ–Ί

    Before you re-share a file, remove the embarrassing field

    Metadata in a ComfyUI PNG is a JSON document with your entire graph in it - prompts, seeds, model names and hashes, plus whatever paths and filenames your nodes happened to embed. People re-share those files constantly. Sometimes they want to strip something first: an old tag, a custom field with a client name in it, a prompt fragment that no longer applies, a UserComment left over from a JPEG round-trip.

    JSON Delete Key removes one key at a given path and hands the JSON back. That's it. The interesting parts are what "path" means and what happens when the JSON is broken.

    How it works

    It shells out to jq - the same tool you'd use in a terminal - running jq 'del(<your path>)' with your JSON on stdin, and returns jq's stdout. Which means:

    • Your Key Path is a jq path expression, not a friendly name. .metadata.unwanted_tag reaches one level down. ["custom"]["UserComment"] works for keys with dots or spaces in them. Anything jq understands, this understands, because it's literally jq.
    • A bare key gets a dot prepended. Type prompt and the node turns it into .prompt for you - a nice touch, since forgetting the leading dot is the classic first mistake.
    • Invalid JSON throws. jq exits non-zero and the node raises jq failed (exit code N) with jq's stderr. Unlike 🏷️ Convert Metadata Format, which quietly returns your input on a parse failure, this one stops the run. That's the better behavior for a destructive edit.

    Empty input in returns {} out. Deleting a path that doesn't exist is a no-op - jq's del doesn't care.

    Inputs and output

    JSON Data is a multiline STRING, default {}. Notably it's not socket-only, so unlike the array nodes you can paste a blob straight in while you're experimenting. In a real workflow it comes from 🏷️ Extract Metadata via a text pass-through, or from πŸ“‘ JSON Merge / πŸ“‘ JSON Set Key.

    Key Path - a STRING, default .key_to_delete (which is a placeholder, not a real path; delete nothing with it and you'll get your JSON back unchanged). This is the field to get right, and the cheapest way to check it is to paste the JSON into a terminal and run jq by hand:

    echo '{"a":1,"b":{"c":2}}' | jq 'del(.b.c)'
    

    If that does what you want, your path is right and the node will behave identically.

    One output: Result (STRING), the modified JSON. Wire it into πŸ“‘ JSON Preview to eyeball it, 🏷️ Convert Metadata Format if you're about to save in a different container, or the pack's metadata writer.

    What this is actually for

    The scenario that makes sense of the node: you've extracted metadata from an image, you want to keep the prompt but not the workflow chunk (the full node graph, which is the part that leaks your pipeline), and you want to save a fresh copy. Extract β†’ Delete Key with .workflow β†’ write. Two nodes and a jq path, and the resulting file has the generation parameters without the graph.

    The counter-argument, and it's a fair one: if you're stripping metadata to post something, you could also just export to JPEG and lose everything by accident. Which works, but loses everything, including the fields that were fine to share. Delete Key is for the surgical version - remove this one thing, keep the rest.

    Install

    Manager: Extensions β†’ Node Pack β†’ search "Honda Nodes" β†’ Install β†’ restart. If you installed by hand, this node needs the installer step, or it will fail with "The 'jq' CLI tool was not found":

    cd ComfyUI/custom_nodes
    git clone --depth 1 https://github.com/Avaray/honda-nodes.git
    cd honda-nodes
    python install.py     # ComfyUI's python; portable Windows: ..\..\..\python_embeded\python.exe install.py
    

    install.py fetches a jq binary appropriate for your platform into honda-nodes/bin. If you already have jq on your PATH, the node will use that instead - the lookup checks PATH first. ComfyUI 0.38.0+ required; the pack is V3-schema only.

    Common issues

    "jq failed (exit code 4)". Syntax error in the key path. A missing closing bracket, a typo'd dot, or a del(.foo that never closes. jq's stderr is printed in the error message - read it, it points at the character.

    "jq failed" with a parse error about invalid JSON. Your JSON Data isn't JSON. Very common cause: Windows paths inside the JSON with single backslashes, because "C:\Users\run1" contains \U and isn't a valid escape. Either double them (\\) or don't put raw paths in metadata. Pipe the string through πŸ“‘ JSON Validate first if you're not sure.

    Nothing was deleted. The path didn't match anything - jq's del silently ignores non-existent paths. Check the shape of your JSON with πŸ“‘ JSON Preview; the key you want may be nested one level deeper than you assumed, or live under custom.PngText rather than at the top.

    You deleted too much. There's no undo. Keep the extracted original in a text node or on disk before you start editing - this is the same advice as everywhere else in ComfyUI's metadata layer, and it's cheaper than re-deriving a graph you stripped.

    Category⚑️ Honda Nodes/πŸ“‘ JSON

    Inputs (2)

    NameTypeDefaultDescription
    json_dataSTRING{}The JSON string to modify.
    key_pathSTRING.key_to_deleteThe jq path for the key to remove, e.g., '.metadata.unwanted_tag'.

    Outputs (1)

    NameTypeDescription
    ResultSTRINGβ€”