A minimal guide to rendering your current knowledge graph to an interactive HTML file with one call. Before you start:
  • Complete Quickstart to understand basic operations
  • Have some data processed with cognify (knowledge graph exists)

What Graph Visualization Shows

  • Nodes (entities, types, chunks, summaries) with color coding
  • Edges with labels and weights; tooltips show extra edge properties
  • Interactive features: drag nodes, zoom/pan, hover edges for details

Full Working Example

import asyncio
import cognee
from cognee.api.v1.visualize.visualize import visualize_graph

async def main():
    await cognee.add(["Alice knows Bob.", "NLP is a subfield of CS."])
    await cognee.cognify()

    await visualize_graph("./graph_after_cognify.html")

asyncio.run(main())
This simple example uses basic text data for demonstration. In practice, you can visualize complex knowledge graphs with thousands of nodes and relationships.

What Just Happened

Step 1: Create Your Knowledge Graph

await cognee.add(["Alice knows Bob.", "NLP is a subfield of CS."])
await cognee.cognify()
First, create your knowledge graph using the standard add → cognify workflow. The visualization works on existing graphs.

Step 2: Generate Visualization

await visualize_graph("./graph_after_cognify.html")
This creates an interactive HTML file with your knowledge graph. You can specify a custom path or use the default location.

Quick Options

Default Location

from cognee.api.v1.visualize.visualize import visualize_graph

# Writes HTML to your home directory by default
await visualize_graph()

Custom Path

from cognee.api.v1.visualize.visualize import visualize_graph

# Writes to the provided file path (created/overwritten)
await visualize_graph("./my_graph.html")

Tips

  • Large graphs: Rendering a very big graph can be slow. Consider building subsets (e.g., smaller datasets) before visualizing
  • Edge weights: If present, control line thickness; multiple weights are summarized and shown in tooltips
  • Static HTML: Files are static HTML; you can open them in any modern browser or share them as artifacts