FrankenTerm

TOON Encoding

243 words1 min read6 subsectionsFrom the README at ft 0.15.21

On this page6
What it looks likeWhen TOON saves tokensWhen TOON saves nothingThe honesty rulePrecedenceDefaults across surfaces

TOON (Token-Optimized Object Notation) is a compact tree serialization optimized for AI-to-AI envelopes. The goal is fewer tokens for the same payload when the consumer is an LLM, not byte-level compression.

What it looks like

A JSON envelope:

json
{"ok": true, "data": {"panes": [{"pane_id": 0, "title": "claude-code"}]}}

The TOON form expresses the same shape with less redundant punctuation and a more LLM-friendly key/value layout. Exact output is library-controlled; the --format toon CLI flag invokes it transparently.

When TOON saves tokens

  • Wide objects with predictable schemas (pane states, event lists). The fixed-key overhead amortizes well.
  • Deeply nested but sparse trees (mission contracts, tx receipts). Keys are emitted once.

When TOON saves nothing

  • Short single-value responses. Overhead of the format setup can dominate.
  • Heavily-stringified payloads (e.g., a get-text response that's 95% raw pane text). The text doesn't compress; only the envelope does.

The honesty rule

The README intentionally avoids fixed percentage claims for TOON savings, because payload shape controls the actual savings. Substrate work for token measurement (the ft-0zoq3 benchmark) lives at docs/perf-ledger/toon-encoding.md. When --stats is passed, the CLI prints the JSON vs TOON byte counts to stderr so callers can verify per-response.

Precedence

CLI flag > FT_OUTPUT_FORMAT > TOON_DEFAULT_FORMAT > json. Operators typically set FT_OUTPUT_FORMAT=toon in agent shells and json for human-facing scripts.

Defaults across surfaces

  • ft robot * defaults to JSON unless --format toon or FT_OUTPUT_FORMAT says otherwise.
  • MCP responses use TOON-compatible types so MCP-aware hosts can render them natively.
  • The web SSE /stream/* endpoints emit JSON (TOON over SSE is intentionally not exposed).