tealeaf-core
Schema-aware data format with human-readable text and compact binary representation.
~36% fewer data tokens than JSON for LLM applications, with zero accuracy loss.
Features
- Dual formats: Human-readable text (
.tl) and compact binary (.tlbx) - Inline schemas:
@struct,@table,@map,@unionfor compact positional data - JSON interop: Bidirectional JSON conversion with automatic schema inference
- Binary format: String deduplication, schema embedding, per-section compression
- CLI:
compile,decompile,validate,to-json,from-json, and more - Derive macros:
#[derive(ToTeaLeaf, FromTeaLeaf)]for DTO conversion (withderivefeature)
Quick Start
[]
= "2.0.0-beta.4"
Parse and convert
use TeaLeaf;
// Parse TeaLeaf text
let doc = parse?;
// Convert to JSON
let json = doc.to_json?;
// Parse from JSON
let doc = from_json?;
// Get the TeaLeaf text (with inferred schemas)
let text = doc.to_tl_with_schemas;
Derive macros
Enable the derive feature for DTO conversion:
[]
= { = "2.0.0-beta.4", = ["derive"] }
use ;
let emp = Employee ;
// Convert to a TeaLeaf document and get text output
let doc = emp.to_tealeaf_doc;
let text = doc.to_tl_with_schemas;
Format Example
JSON input:
TeaLeaf text output (with auto-inferred schema):
@struct User (name: string, age: int)
users: @table User [
("Alice", 30)
("Bob", 25)
]
License
MIT