Laravel TOON Rust
TOON encoding and decoding for Laravel for Rust. The same data as JSON, in far fewer tokens.
cargo add laravel-toon-rust
Try it
Paste any JSON. The crate encodes it as TOON and measures what that saves.
orders[4]{id,customer,total,paid}:
1041,Ada,89.5,true
1042,Grace,120,false
1043,Linus,42.25,true
1044,Margaret,310,true
The Rust version of Laravel TOON. Paste your own JSON in the demo above to see what it saves.
What it does
-
Built to the spec
Passes all 590 fixtures of the TOON v4.1 spec test suite, and writes the same TOON as Laravel TOON for PHP. Decoding gives back the original structure.
-
Anything that serializes
encode() takes any Serialize value, decode_as::<T>() reads into a type of your own, and every serializable value gets to_toon().
-
A response type
Return a ToonResponse from a handler to answer with text/toon, such as a list of models for an agent.
-
Fewer tokens on request
Leave out nulls, empty strings or keys at every depth, alias long keys, truncate strings and cap float precision. diff() measures the saving first.
Hi, I'm Mischa. I've been shipping products and building ventures for over a decade. First exit at 25, second at 30. Now Partner & CPO at Ryde Ventures, an AI venture studio in Amsterdam. Currently shipping Stagent, TAP and Steddle. I write about what I learn along the way. More about me.
You might also enjoy: My simplified Ralph loop setup for Claude Code.