Skip to main content
Render a compiled graph as Mermaid text or a PNG image to inspect topology and debug routing. For an interactive UI, use LangSmith Studio with a local server. You can visualize any compiled graph that exposes get_graph(), including StateGraph. See the Graph reference. The examples below use the same small graph in both languages: two nodes, a conditional edge from node1, and a loop back from node2.

Mermaid

Call draw_mermaid() on the drawable graph to get Mermaid syntax. Paste the string into any Mermaid renderer, or keep it in docs and PRs.

PNG

Render the same graph as a .png with one of three approaches:
  • Mermaid.ink API (default; no extra packages)
  • Mermaid + Pyppeteer (pip install pyppeteer)
  • Graphviz (pip install pygraphviz, plus the system Graphviz binary)
Using Mermaid.ink By default, draw_mermaid_png() uses the Mermaid.ink API to generate the diagram.
Simple graph visualization Using Mermaid + Pyppeteer
Using Graphviz

See also