Expand description
§TOON Format - Token-Oriented Object Notation
A Rust implementation of the TOON (Token-Oriented Object Notation) format. TOON is a compact, human-readable serialization format designed to minimize tokens when sending structured data to Large Language Models (LLMs).
§Quick Start
use toon_format_rs::{parse, to_string, Value};
// Parse TOON string
let input = r#"id: 123
name: Alice
active: true"#;
let value = parse(input).unwrap();
assert_eq!(value.get("id").unwrap().as_i64(), Some(123));
// Serialize to TOON
let output = to_string(&value).unwrap();
assert!(output.contains("id: 123"));§Features
- Compact: 30-60% fewer tokens than JSON for uniform arrays
- Human-readable: YAML-like indentation with CSV-like tabular arrays
- Schema-aware: Explicit array lengths and field lists
- Lossless: Convert JSON → TOON → JSON without data loss
- LLM-optimized: Designed specifically for LLM prompts
Re-exports§
pub use error::Error;pub use error::Result;pub use lexer::Lexer;pub use lexer::Token;pub use parser::parse;pub use parser::Parser;pub use serializer::to_string;pub use serializer::to_string_pretty;pub use serializer::Delimiter;pub use serializer::SerializeOptions;pub use serializer::Serializer;pub use value::Value;
Modules§
Functions§
- json_
to_ toon - Converts a JSON string to TOON format
- toon_
to_ json - Converts a TOON string to JSON format
- toon_
to_ json_ pretty - Converts a TOON string to pretty-printed JSON