| Crates.io | serde_toon |
| lib.rs | serde_toon |
| version | 0.2.0 |
| created_at | 2025-10-29 16:45:36.78218+00 |
| updated_at | 2025-10-31 03:25:17.992134+00 |
| description | A Serde-compatible TOON (Token-Oriented Object Notation) serialization library |
| homepage | https://github.com/hxphsts/serde_toon |
| repository | https://github.com/hxphsts/serde_toon |
| max_upload_size | |
| id | 1906931 |
| size | 230,935 |
A Serde-compatible TOON serialization library for Rust.
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
[
{
"id": 1,
"name": "Alice",
"email": "alice@example.com",
"active": true
},
{
"id": 2,
"name": "Bob",
"email": "bob@example.com",
"active": true
}
]
// TOON: 86 characters (50% reduction)
[2]{active,email,id,name}:
true,alice@example.com,1,Alice
true,bob@example.com,2,Bob
See examples/token_efficiency.rs.
[dependencies]
serde = { version = "1.0", features = ["derive"] }
serde_toon = "0.2"
use serde::{Deserialize, Serialize};
use serde_toon::{to_string, from_str};
#[derive(Serialize, Deserialize)]
struct User {
id: u32,
name: String,
}
let user = User { id: 123, name: "Alice".into() };
let toon = to_string(&user)?; // Serialize to TOON
let back: User = from_str(&toon)?; // Deserialize from TOON
use serde_toon::{toon, to_string};
let data = toon!({
"users": [
{"id": 1, "name": "Alice"},
{"id": 2, "name": "Bob"}
],
"active": true
}); // toon! macro -> serde_toon::Value
let serialized = to_string(&data)?;
See examples/dynamic_values.rs, examples/macro.rs.
See https://docs.rs/serde_toon
MIT OR Apache-2.0