Deterministic, AI-friendly diagram syntax with powerful CLI tooling
Graphrite is a strict subset of Mermaid designed for reliable parsing, validation, and rendering. Perfect for automated workflows, documentation generation, and anywhere you need predictable diagram behavior.
- 🎯 Deterministic parsing - Same input always produces same output
- 🤖 AI-friendly syntax - Simple, unambiguous grammar perfect for LLMs
- ⚡ Fast validation - Comprehensive error checking with precise diagnostics
- 🎨 Multiple outputs - Generate DOT, SVG, or JSON AST
- 📝 Strict subset - Compatible with Mermaid but removes ambiguity
- Rust toolchain (1.70+)
git clone https://github.com/bwl/graphrite.git
cd graphrite
cargo build --release# Validate a diagram
cargo run -p graphrite-cli -- check samples/valid/simple_flow.mmd
# Generate SVG
cargo run -p graphrite-cli -- render --format svg samples/valid/simple_flow.mmd > output.svg
# Parse to JSON AST
cargo run -p graphrite-cli -- parse samples/valid/simple_flow.mmd%% Diagram: Simple Workflow
direction LR
start["Start Process"]
validate["Validate Input"]
process["Process Data"]
store["Store Results"]
end_success["Success"]
end_fail["Failed"]
start --> validate
validate --> process
validate --> end_fail
process --> store
store --> end_success
| Command | Description | Example |
|---|---|---|
check |
Validate diagram syntax | cargo run -p graphrite-cli -- check file.mmd |
parse |
Output JSON AST | cargo run -p graphrite-cli -- parse file.mmd |
lint |
Human-readable validation | cargo run -p graphrite-cli -- lint --pretty file.mmd |
render |
Generate DOT/SVG output | cargo run -p graphrite-cli -- render --format svg file.mmd |
fmt |
Format diagram (normalize) | cargo run -p graphrite-cli -- fmt --check file.mmd |
# From file
cargo run -p graphrite-cli -- check diagram.mmd
# From stdin
echo "direction LR\na[\"Start\"]\nb[\"End\"]\na --> b" | cargo run -p graphrite-cli -- ast- 📋 Valid samples:
samples/valid/- Correct syntax examples - ❌ Invalid samples:
samples/invalid/- Common errors and edge cases - 🖼️ Rendered output:
docs/examples/- Generated SVG examples
Graphrite enforces strict validation for reliable parsing:
- Snake_case identifiers:
my_node,process_step✅ (notmyNode,process-step❌) - Quoted labels:
node["My Label"]✅ (notnode[My Label]❌) - Required direction: First line must be
direction LRordirection TD - No orphan nodes: Every node must have at least one edge
- No dangling edges: All edge references must point to declared nodes
- Line length limit: 100 characters maximum
- Getting Started - Step-by-step tutorial
- Syntax Specification - Complete language reference
- Error Codes - Validation error reference
- Development Guide - Contributing and architecture
- 📖 Documentation - Generate diagrams in docs with guaranteed consistency
- 🤖 AI Workflows - LLMs can generate reliable Graphrite syntax
- ⚙️ CI/CD Integration - Validate diagrams in automated pipelines
- 📊 Data Visualization - Convert structured data to visual flowcharts
0- Success1- Validation errors or parsing failures
MIT License - see LICENSE file for details.