Overview
The graph export feature allows you to visualize your knowledge graph in multiple formats. Export to Graphviz DOT for powerful graph rendering, JSON for D3.js web visualizations, or Mermaid for documentation and Markdown files.
Export Formats
| Format | Description | Best For |
|---|---|---|
dot | Graphviz DOT format | High-quality renderings, complex graphs, PDF/PNG export |
json | D3.js compatible JSON | Interactive web visualizations, custom applications |
mermaid | Mermaid diagram syntax | Documentation, GitHub/GitLab Markdown, wikis |
Basic Export
# Export to Graphviz DOT
trix graph export --format dot --output graph.dot
# Export to JSON (D3.js compatible)
trix graph export --format json --output graph.json
# Export to Mermaid
trix graph export --format mermaid --output graph.md
# Output to stdout (for piping)
trix graph export --format dotFiltering Options
Filter the exported graph by space, tags, relationship types, or time range:
# Export a specific space
trix graph export --format dot --space work --output work-graph.dot
# Filter by tags
trix graph export --format json --tags "adr,decision" --output decisions.json
# Filter by relationship types
trix graph export --format mermaid --types "depends_on,implements"
# Time-based filtering (relative duration string, e.g. 30d, 7d, 24h)
trix graph export --format dot --since 30d
# Combine filters
trix graph export --format json \
--space project-x \
--tags architecture \
--since 30d \
--output architecture.jsonDepth Control
Control how deep the graph traversal goes from each node:
# Default depth (2 levels)
trix graph export --format dot --output graph.dot
# Shallow graph (direct connections only)
trix graph export --format dot --depth 1 --output shallow.dot
# Deep graph (3 levels of connections)
trix graph export --format dot --depth 3 --output deep.dotHigher depth values include more relationships but may result in very large graphs. Start with depth 1 or 2 and increase as needed.
DOT Format (Graphviz)
The DOT format produces files compatible with Graphviz tools for high-quality rendering:
# Export to DOT
trix graph export --format dot --output graph.dot
# Render to PNG using Graphviz
dot -Tpng graph.dot -o graph.png
# Render to PDF
dot -Tpdf graph.dot -o graph.pdf
# Render to SVG (scalable)
dot -Tsvg graph.dot -o graph.svg
# Use different layout engines
neato -Tpng graph.dot -o graph-neato.png # Spring model
fdp -Tpng graph.dot -o graph-fdp.png # Force-directed
circo -Tpng graph.dot -o graph-circo.png # CircularExample DOT output:
digraph TrixMemories {
rankdir=LR;
node [shape=box, style=rounded];
edge [fontsize=10];
// Nodes
"mem_abc" [label="Sarah Chen\n(team,architect)",
color="#e74c3c", fillcolor="#2e1a1a", style="filled,rounded"];
"mem_def" [label="ADR-001: Use PostgreSQL\n(decision,database)",
color="#5a9a8a", fillcolor="#1a2e2a", style="filled,rounded"];
// Edges
"mem_abc" -> "mem_def" [label="approved"];
"mem_def" -> "mem_ghi" [label="implements"];
}JSON Format (D3.js)
The JSON format is optimized for D3.js force-directed graphs and web visualizations:
# Export to JSON
trix graph export --format json --output graph.jsonExample JSON output:
{
"metadata": {
"exported_at": "2026-01-15T10:30:00Z",
"node_count": 45,
"edge_count": 72,
"filters": {
"space": "work",
"depth": 2
}
},
"nodes": [
{
"id": "mem_abc123",
"label": "Sarah Chen",
"tags": ["team", "architect"],
"type": "memory",
"group": 1
},
{
"id": "mem_def456",
"label": "ADR-001: Use PostgreSQL",
"tags": ["decision", "database"],
"type": "memory",
"group": 2
}
],
"links": [
{
"source": "mem_abc123",
"target": "mem_def456",
"label": "approved",
"type": "approved"
}
]
}The group field can be used for D3.js coloring based on memory clusters
or categories.
Mermaid Format
Mermaid diagrams render directly in GitHub, GitLab, and documentation tools:
# Export to Mermaid
trix graph export --format mermaid --output graph.md
# With title
trix graph export --format mermaid --title "Project Architecture" --output arch.mdExample Mermaid output:
---
title: Knowledge Graph
---
graph LR
%% Styles
classDef person fill:#2e1a1a,stroke:#e74c3c
classDef decision fill:#1a2e2a,stroke:#5a9a8a
classDef concept fill:#1a1a2e,stroke:#5a5a9a
%% Nodes
mem_abc123["Sarah Chen"]:::person
mem_def456["ADR-001: PostgreSQL"]:::decision
mem_ghi789["Database Layer"]:::concept
%% Relationships
mem_abc123 -->|approved| mem_def456
mem_def456 -->|implements| mem_ghi789Command Reference
| Option | Description |
|---|---|
--format | Output format: dot, json, mermaid |
--output, -o | Output file path (stdout if not specified) |
--space | Filter by space (name or ID) |
--tags | Filter by tags (comma-separated) |
--types | Filter by relationship types |
--since | Duration filter (e.g. 30d, 7d, 24h) |
--depth | Traversal depth (default: 2) |
--title | Title for the diagram (Mermaid only) |
Use Cases
Architecture Documentation
# Export architecture decisions
trix graph export --format mermaid \
--tags "adr,architecture" \
--output docs/architecture.md
# Include in README
echo '## Architecture Decisions' >> README.md
cat docs/architecture.md >> README.mdTeam Knowledge Map
# Export team knowledge graph
trix graph export --format dot \
--space team \
--types "owns,leads,mentors" \
--output team-knowledge.dot
# Render to image
dot -Tpng team-knowledge.dot -o team-knowledge.pngInteractive Web Dashboard
# Export for D3.js visualization
trix graph export --format json --output public/graph-data.json
# Use in D3.js force-directed graph
# (Example D3.js code would consume this JSON)Next Steps
- Conflict Detection - Find contradictory information
- Relationships - Understanding typed relationships
- Graph API - Programmatic graph access