ComfyUI Context Menu API Migration: Canvas and Node Menus
Migrate ComfyUI extensions from deprecated monkey-patching to the context menu API: canvas and node menus, conditional items, submenus, and debugging tips.
This guide helps you migrate from the deprecated monkey-patching approach to the new context menu extension API.The old approach of monkey-patching LGraphCanvas.prototype.getCanvasMenuOptions and nodeType.prototype.getExtraMenuOptions is deprecated:
If you see deprecation warnings in your browser console, your extension is using the old API and should be migrated.
Migrating Canvas Menus
Old Approach (Deprecated)
The old approach modified the prototype during extension setup:
This declarative approach is cleaner and matches the patterns used throughout the ComfyUI codebase.
While a callback-based approach with has_submenu: true and new LiteGraph.ContextMenu() is also supported, the declarative submenu property is preferred for better maintainability.
// ❌ Signs of old API:LGraphCanvas.prototype.getCanvasMenuOptions = function() { /* ... */ }nodeType.prototype.getExtraMenuOptions = function() { /* ... */ }
Understanding Deprecation Warnings
If you see this warning in the console:
[DEPRECATED] Monkey-patching getCanvasMenuOptions is deprecated. (Extension: "MyExtension")Please use the new context menu API instead.See: https://docs.comfy.org/custom-nodes/js/context-menu-migration
Your extension is using the old approach and should be migrated.
Verifying Migration Success
After migration:
Remove all prototype modifications from setup() and beforeRegisterNodeDef()