When structured data moves from APIs into prompts, logs, or debug snapshots, JSON often carries more syntax than signal. Repeated keys, quotes, and braces are helpful for machines, but they can become expensive and noisy in the places where developers and language models need to read quickly.
That is the problem TOON is built to solve.
TOON, short for Token-Optimized Object Notation, is a compact text format for structured data. In Laravel projects it gives you a readable alternative for internal workflows where payload size and scanability both matter.
The original motivation was practical:
I wanted something that still felt natural in Laravel applications and could be decoded back safely when needed.
TOON works especially well with repeated structured rows. Instead of repeating every key on every object, TOON can promote the shared field list into a single header and render the values as rows.
Example PHP data:
$payload = [
'users' => [
['id' => 1, 'name' => 'Alice', 'active' => true],
['id' => 2, 'name' => 'Bob', 'active' => false],
],
];
TOON output:
users:
items[2]{id,name,active}:
1,Alice,true
2,Bob,false
That structure is easier to scan than raw JSON, and it also reduces repetition.
The package is designed to feel familiar inside Laravel.
use Sbsaga\Toon\Facades\Toon;
$toon = Toon::encode($payload);
$decoded = Toon::decode($toon);
$diff = Toon::diff($payload);
There are helpers too:
$toon = toon_encode($payload);
$decoded = toon_decode($toon);
And collections can be encoded directly:
$toon = collect($payload['users'])->toToon();
The package now leans harder into trust and predictability:
TOON is not a replacement for JSON everywhere. It is most useful in:
That is the sweet spot: smaller structured payloads without giving up readability.
How can I help you explore Laravel packages today?