Preview HTML
Preview HTML and interactive model visualizations right in the node
- html
- HTML
Most custom nodes output images, tensors, or numbers. This one outputs a web page - right there inside the node, rendered live on your canvas. PreviewHTML takes HTML content (or an object that can produce it) and displays it as a little web view in ComfyUI. It's the "display" half of the notebook workflow: your NotebookCell builds a visualization, PreviewHTML shows it to you.
The use case that makes it click is the pack's own demo: inspecting GPT-2's attention weights with the circuitsvis library - the same interactive visualizations you see in the Anthropic and transformer-interpretability write-ups. Your cell runs a forward pass, packages up an attention or saliency visualization, hands it to PreviewHTML, and you get an interactive widget instead of squinting at a tensor. It also works for anything that produces Jupyter-style HTML: dataframes, interactive plots, or a little status dashboard summarizing what your workflow just did.
How it works
The node has one optional input, html (generic *), which accepts:
- a plain HTML string,
- a
circuitsvisRenderedHTMLobject, - any object with a
_repr_html_()method (the Jupyter/Colab convention), - any object with an
__html__()method.
It resolves them in exactly that order - _repr_html_() first, then __html__(), then treat it as a string, then fall back to str() - and sends the result to the frontend, which renders it inside the node. The single output, HTML (STRING), also passes the raw HTML string through, so the node doubles as a generic HTML-string provider if you want to log or reuse it. Leave the input unconnected and you get a harmless empty div; if extracting the HTML throws, the node shows a tidy red error box with the exception message so you can see what broke.
Because the rendering happens in your browser, PreviewHTML inherits the usual web-view trust model: the HTML it draws is code running in your page, and the README's sandbox warning applies to the whole pack. Don't paste previews of untrusted workflow HTML and then click around in them expecting protection.
Install
It's in the same pack as NotebookCell, so one install gets you all three:
cd ComfyUI/custom_nodes
git clone https://github.com/liusida/ComfyUI-Notebook
Restart ComfyUI. The node itself needs nothing extra - requirements.txt only lists matplotlib, and even that's for the plotting cells, not for HTML. If you want circuitsvis specifically, that's a separate pip install circuitsvis in your ComfyUI environment, and it's not bundled.
Troubleshooting
- Red error box in the node - the object's
_repr_html_()(or whatever method it resolved to) raised. The message in the box is the exception; fix that and rerun. - Blank preview - the input resolved to a string but the HTML didn't render. Check it's valid standalone HTML, not a fragment that needs JS context it doesn't have.
- Doesn't show anything interactive - some visualization libraries ship their own dependencies or need a specific browser;
circuitsvisneeds the page to load its JS from CDNs, so the browser needs internet access, same as the Monaco editor this pack uses for syntax highlighting.
If you're not doing model-interpretation or building HTML dashboards, you can skip this one - but if you've ever wanted to look inside a model rather than at its outputs, it's the most fun node in the pack.
Inputs (1)
| Name | Type | Default | Description |
|---|---|---|---|
| htmlopt | * | HTML content, circuitsvis RenderedHTML object, or any object with _repr_html_() or __html__() method |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| HTML | STRING | — |