serde_toon
A Serde-compatible TOON serialization library for Rust.
What is TOON?
TOON (Token-Oriented Object Notation) is a compact serialization format optimized for LLMs, using 30-60% fewer tokens than JSON.
Example - Same data, different sizes:
// JSON: 171 characters
// TOON: 86 characters (50% reduction)
:
true,alice@example.com,1,Alice
true,bob@example.com,2,Bob
See examples/token_efficiency.rs.
Quick Start
[]
= { = "1.0", = ["derive"] }
= "0.2"
use ;
use ;
let user = User ;
let toon = to_string?; // Serialize to TOON
let back: User = from_str?; // Deserialize from TOON
Dynamic Values
use ;
let data = toon!; // toon! macro -> serde_toon::Value
let serialized = to_string?;
See examples/dynamic_values.rs, examples/macro.rs.
Features
- Full Serde integration
- Zero-copy deserialization
- Configurable output
- Rich error messages
- No unsafe code
Documentation
See https://docs.rs/serde_toon
License
MIT OR Apache-2.0