Token-efficient serialization for AI agents. 50%+ fewer tokens, streaming validation, human-readable.
Tokens cost money. Tokens are context. Every token matters.
JSON: {"messages":[{"role":"user","content":"Hi"},{"role":"assistant","content":"Hello!"}],"model":"gpt-4"}
GLYPH: {msgs:[{r:u c:Hi} {r:a c:Hello!}] mdl:gpt-4}
30 tokens β 16 tokens (47% reduction)
JSON wastes tokens on redundant syntax. Every ", :, and , consumes context window. GLYPH eliminates the waste:
1. 40-60% Token Reduction: No quotes, no colons, no commas, abbreviated keys 2. Scales with Data: Larger datasets = bigger savings (50 rows β 62% savings) 3. Streaming Validation: Detect errors mid-stream, cancel immediately 4. Human-Readable: Still debuggable, unlike binary formats
Tokens are what matter for LLM costs and context windows.
| Data Shape | JSON Tokens | GLYPH Tokens | Savings |
|---|---|---|---|
| LLM message | 10 | 6 | 40% |
| Tool call | 26 | 15 | 42% |
| Conversation (25 msgs) | 264 | 134 | 49% |
| Search results (25 rows) | 456 | 220 | 52% |
| Search results (50 rows) | 919 | 439 | 52% |
| Tool results (50 items) | 562 | 214 | 62% |
Average: 50%+ token savings on real-world data.
Detect errors as they stream, cancel immediatelyβnot after full generation.
{tool=unknown... β Cancel mid-stream, save the remaining tokensWhy it matters: Catch bad tool names, missing params, constraint violations as they appear. Save tokens, save money, reduce latency.
Homogeneous lists compress to tables automatically:
@tab _ [name age city]
Alice 28 NYC
Bob 32 SF
Carol 25 Austin
@end50-62% fewer tokens than JSON arrays. Scales linearlyβmore rows = more savings.
SHA-256 hashing prevents concurrent modification conflicts. Enables checkpoint/resume workflows.
Drop-in replacement. Bidirectional conversion. One-line change.
| Language | Installation | Documentation |
|---|---|---|
| Python | pip install glyph-serial |
Python Guide β |
| Go | go get github.com/Neumenon/glyph |
Go Guide β |
| JavaScript | npm install glyph-js |
JS Guide β |
| Rust | cargo add glyph-codec |
Rust Guide β |
| C | make |
C Guide β |
import glyph
# JSON to GLYPH
data = {"action": "search", "query": "AI agents", "limit": 5}
glyph_str = glyph.json_to_glyph(data)
# Result: {action=search limit=5 query="AI agents"}
# GLYPH to JSON
original = glyph.glyph_to_json(glyph_str)
# Parse and access
result = glyph.parse('{name=Alice age=30}')
print(result.get("name").as_str()) # Aliceimport "github.com/Neumenon/glyph/glyph"
text := `{action=search query=weather limit=10}`
val, _ := glyph.Parse([]byte(text))
action := val.Get("action").String() // "search"import { parse, emit, fromJSON } from 'glyph-js';
const value = parse('{action=search query=test}');
console.log(value.get('action')); // 'search'
const text = emit(fromJSON({ name: 'Alice', scores: [95, 87, 92] }));
// {name=Alice scores=[95 87 92]}More examples: 5-Minute Tutorial β
- LLMs reading structured data (tool responses, state, batch data)
- Streaming validation needed (real-time error detection)
- Token budgets are tight
- Multi-agent systems with state management
- LLMs generating output (they're trained on JSON)
- Existing JSON-only system integrations
Best Practice: HybridβLLMs generate JSON, serialize to GLYPH for storage/transmission.
Null: β
or _ List: [1 2 3]
Bool: t / f Map: {a=1 b=2}
Int: 42, -7 Struct: Team{name=Arsenal}
Float: 3.14, 1e-10 Sum: Some(42) / None()
String: hello Ref: ^user:abc123
Bytes: b64"SGVsbG8=" Time: 2025-01-13T12:00:00Z
vs JSON: No commas Β· = not : Β· bare strings Β· t/f bools Β· β
null
- 5-Minute Quickstart - Get running fast
- Comprehensive Guide - Features and patterns (coming soon)
- AI Agent Patterns - LLM integration recipes
- Technical Specifications - Loose Mode, GS1, type system (coming soon)
- API Reference - Per-language API docs (coming soon)
- Visual Guide - Interactive examples
- LLM Accuracy Report - How LLMs handle GLYPH
- Performance Benchmarks - Speed and token metrics
- Cookbook - 10 practical recipes
- All Reports β
Tool Calling: Define tools in GLYPH (40% fewer tokens in system prompts), validate during streaming and cancel bad requests immediately.
Agent State: Store conversation history with 49% fewer tokens. Patch with base hashes for concurrent safety.
Batch Data: Auto-tabular mode for embeddings, search results, logs (50-62% token reduction). 50 search results? 919 β 439 tokens.
Loose Mode: Schema-optional, JSON-compatible. Spec β
GS1 Streaming: Frame protocol with CRC-32 and SHA-256 verification. Spec β
Agent Patterns: Tool definitions, state patches, ReAct loops, multi-agent coordination. Guide β
Codec Speed (Go implementation):
- Canonicalization: 2M+ ops/sec
- Parsing: 1.5M+ ops/sec
glyph/
βββ README.md β You are here
βββ docs/ β Documentation
β βββ QUICKSTART.md
β βββ AGENTS.md
β βββ COOKBOOK.md
β βββ ...
βββ go/ β Go implementation
βββ py/ β Python implementation
βββ js/ β JavaScript/TypeScript
βββ rust/ β Rust implementation
βββ c/ β C implementation
βββ tests/ β Cross-language tests
Contributions welcome! Please see:
- Issues - Bug reports and feature requests
- Discussions - Questions and ideas
Apache 2.0 - See LICENSE for details.
Built by Neumenon Β· Making AI agents more efficient, one token at a time.