This repository provides a lightweight, pure‑Python implementation of the LiteGraph‑based workflow loader used by ComfyUI. It focuses solely on the data model needed to read a ComfyUI workflow generated by the JavaScript LiteGraph library and convert it to the ComfyAPI prompt format. All graphical‑interface code from the original project is intentionally omitted, keeping the library small and dependency‑free.
python -m venv venv_litegraph
source venv_litegraph/bin/activate # Windows: venv_litegraph\Scripts\activate
pip install -e . # editable install for development (src layout)
pip install -r requirements.txt # development and test dependenciesfrom litegraph_py import load_workflow_json, graph_to_prompt
from litegraph_py.loader import load_object_info
# Load a workflow JSON file (widget values will be unnamed)
graph = load_workflow_json("path/to/workflow.json")
# Or load with object_info.json for named widget values
graph = load_workflow_json("path/to/workflow.json", object_info=load_object_info("path/to/object_info.json"))
# Convert to the ComfyAPI prompt format
workflow_json, api_prompt = graph_to_prompt(graph)
print(api_prompt) # dict ready for the ComfyUI APIpython -m litegraph_py path/to/workflow.json [-o out.json] [--sort] [--object-info object_info.json]-o/--outputwrites the JSON to a file instead of stdout.--sorttopologically sorts nodes before emitting the prompt.--object-infopath to anobject_info.jsonfile to reconstruct named widget values.
When adding new tests, ensure they target the pure‑logic aspects of the library and avoid any UI‑related code. Feel free to submit pull requests that expand coverage of node/link handling or improve the prompt conversion algorithm.