ZML_节点代码查看器
Read the source of any node without leaving ComfyUI
- 任意输入
- 节点类名
- 节点文件名
- 节点代码
Every serious ComfyUI user eventually has the same urge: "what is this node actually doing?" Normally the answer means finding the Python file in custom_nodes, opening it in an editor, and scrolling. ZML_CodeViewerNode (ZML_节点代码查看器) pulls the source code of any upstream node out and shows it to you - no file hunting, no editor, just connect the node and read the class that produced the thing you're looking at.
What it is
A code-inspection tool from ComfyUI-ZML-Image, and it's one of the more useful "developer comfort" nodes in the pack. The inputs:
- 任意输入 (any type) - connect it to any node's output. The tooltip says it plainly: it automatically finds the upstream node's source code. Because the socket is wildcard-typed, it can hang off almost anything.
- 显示完整代码 (BOOLEAN, default true) - true shows the whole class; false shows only the relevant function/method.
- 包含导入语句 (BOOLEAN, default false) - whether to include the
importlines at the top. - 不执行上游 (BOOLEAN, default false) - don't run the upstream node, just read its code. Handy when the upstream is expensive and you only want to inspect it.
Outputs, all STRING:
- 节点类名 - the class name (e.g.
ZML_AddTextWatermark). - 节点文件名 - which file defines it.
- 节点代码 - the extracted source.
How it works
The backend scans installed node files (with a cache so it only does this once), maps class names to file paths, and walks backward through the graph from whatever you connected to find the defining class. Then it extracts the source - the full class or just the function, depending on your toggle - and returns it as strings you can read in a text display node or dump to a file. The lazy input means it can trace through wildcard connections to the original producer, which is exactly what you want when a reroute or a switch sits between you and the real node.
Install and gotchas
Standard pack install:
cd ComfyUI/custom_nodes
git clone https://github.com/zml-w/ComfyUI-ZML-Image
or ComfyUI Manager → ComfyUI-ZML-Image, restart. Nothing extra.
The caveats are honest ones. First, the node needs the upstream class to be findable - nodes defined dynamically (some packs generate classes at runtime) or in minified JS-driven files may not resolve, and you'll get a lookup miss rather than code. Second, the README notes this is a "get the node's code and print the python path" utility, added because the author wanted it for debugging - it's a tinkerer's tool, so temper expectations for perfect output on every exotic pack. Third, it returns code as text; the natural way to read it is a text/multiline display node or a file writer, and yes, you could absolutely use the 节点代码 output to save a copy of another node's logic. Chinese-first UI, English patch at github.com/zml-w/ZZZ_ZML_English_Patch, one-person pack, no English community - but for a "read my code" utility, the code itself is the documentation.
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| 任意输入 | * | 连接任意节点输出,会自动查找上游节点的源代码 | |
| 显示完整代码opt | BOOLEAN | true | True显示完整类代码,False只显示函数/方法代码 |
| 包含导入语句opt | BOOLEAN | false | 是否在代码开头包含import语句 |
| 不执行上游opt | BOOLEAN | false | — |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| 节点类名 | STRING | — |
| 节点文件名 | STRING | — |
| 节点代码 | STRING | — |