- extend node definitions with custom behavior, badges, previews, and lifecycle hooks;
- add widgets, panels, menus, commands, and other interface features;
- read and edit graphs, nodes, slots, and links through documented handles;
- drive queueing, execution feedback, settings, storage, and authenticated backend requests.
Main concepts
Learn handles, lifecycle, snapshots, capabilities, and how the frontend API is structured.
Extend a node with JavaScript
Follow a complete tutorial that adds a badge, a menu action, and lifecycle behavior to an existing node.
How-to guides
Find focused guides for registration, definitions, graphs, slots, widgets, UI, execution, and services.
Reference
Look up imports, common patterns, rules, versioning, and exact API signatures.
What you can build
Anyone who can write JavaScript can change how a node looks and behaves in the ComfyUI editor: custom widgets, live previews, node badges, context menus, commands, panels, and graph automation. Almost any frontend behavior built againstapp, LiteGraph, or prototype patching has a path to V2. Keep the behavior users rely on while replacing private implementation hooks with documented handles, events, and UI contributions.
You bring the user experience. Comfy provides the editor, the graph model, and a stable extension API.
How the API fits together
The normal authoring flow is:
- Ship the extension module inside the pack’s
v2/web/distribution. - Import
comfyfrom/comfy/api/v2.js. - Declare hard dependencies with
comfy.require()and probe optional ones withcomfy.supports(). - Extend a node definition and attach lifecycle, widget, and UI behavior.
- Read and mutate graph state through documented handles instead of private objects.
Extend a node through comfy
The JavaScript API represents ComfyUI nodes, graphs, widgets, and services through documented handles. Use those handles instead of patching private application objects.
V1 and V2 pack layout
A converted pack keeps its existing V1 distribution at the top level and adds a complete V2 replacement underv2/.
v2/ as the V2 pack root. It does not merge the two trees or fall back to a V1 file that is missing from v2/.
V2 frontend modules and their assets live under v2/web/. A similarly named file in the root web/ tree is not a V2 asset.
For an existing pack, the recommended migration path is MAGIC PATCH, a local conversion tool that drives Claude Code or Codex on your own machine. See Migrate legacy frontend code for the frontend mappings it produces.
Build durable node code
Use documentedcomfy handles, events, and UI contributions instead of depending on window.app, LiteGraph internals, application stores, or host DOM. Published extension points can be versioned, tested, and kept compatible as ComfyUI evolves.
Where to go next
- Read Use JavaScript handles and lifecycle for the frontend mental model.
- Follow the Extend a node with JavaScript tutorial.
- Study the example packs for tested, runnable patterns.
- Use the focused JavaScript how-to guides while building a real pack.
- Open the Reference overview when you need a rule or exact signature.
comfy-api.d.ts. If prose and a generated signature disagree, follow the declaration and report the documentation mismatch.