toon-format 0.2.1

Token-Oriented Object Notation (TOON) - a token-efficient JSON alternative for LLM prompts
Documentation

TOON Format for Rust

Crates.io Documentation License: MIT

Token-Oriented Object Notation is a compact, human-readable format designed for passing structured data to Large Language Models with significantly reduced token usage.

Example

JSON (verbose):

{
  "users": [
    { "id": 1, "name": "Alice", "role": "admin" },
    { "id": 2, "name": "Bob", "role": "user" }
  ]
}

TOON (compact):

users[2]{id,name,role}:
  1,Alice,admin
  2,Bob,user

Resources

Usage

use serde_json::json;
use toon_format::{encode_default, decode_default};

let data = json!({
  "users": [
    {"id": 1, "name": "Alice"},
    {"id": 2, "name": "Bob"}
  ]
});

let toon = encode_default(&data)?;
let decoded = decode_default(&toon)?;
assert_eq!(decoded, data);

Contributing

Interested in implementing TOON for Rust? Check out the specification and feel free to contribute!

License

MIT License © 2025-PRESENT Johann Schopplich