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
Code in Action
import asyncio
import cognee
import os
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()
visualize_graph_path = os.path.join(
os.path.dirname( __file__ ), ".artifacts" , "graph_visualization.html"
)
await visualize_graph(visualize_graph_path)
if __name__ == "__main__" :
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
visualize_graph_path = os.path.join(
os.path.dirname( __file__ ), ".artifacts" , "graph_visualization.html"
)
await visualize_graph(visualize_graph_path)
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
Additional examples
Additional examples about Graph visualization are available on our github .
Code Graph Learn about code graph visualization
Core Concepts Understand knowledge graph fundamentals
Custom Data Models Learn about custom data models