How TOON Saves Tokens
TOON (Token-Oriented Object Notation) is a compact format designed specifically for LLM inputs. It reduces token usage by:
- 1Eliminating redundant structure — No repeated keys, braces, or brackets for uniform arrays
- 2Tabular encoding — Arrays of objects become header + rows (like CSV)
- 3Minimal quoting — Strings are unquoted by default, quoted only when necessary
Important: Formatted vs Minified JSON Savings depend on your JSON baseline. Real-world API calls use minified JSON (no whitespace). Against minified JSON: uniform arrays save 20-35%, but nested objects and configs can INCREASE token usage by 15-20%. Use the Minify button above to see accurate comparisons.
{
"users": [
{"id": 1, "name": "Alice", "role": "admin"},
{"id": 2, "name": "Bob", "role": "user"},
{"id": 3, "name": "Carol", "role": "user"}
]
}users[3]{id,name,role}:
1,Alice,admin
2,Bob,user
3,Carol,userWhen to Use TOON
TOON works best with uniform arrays. Click any example to try it - use Minify to see real-world savings.
Token Savings Calculator
Estimate token impact based on data size and structure. Compared to minified JSON.
Estimates assume minified JSON baseline (no whitespace). TOON saves tokens for uniform arrays but can increase token usage for nested structures. Use the converter above with real data for accurate measurements.
JSON vs TOON: When to Use Each
TOON saves tokens for uniform arrays but can increase tokens for nested structures. These estimates assume minified JSON (no whitespace).
| Data Type | Example | vs Minified JSON | Notes |
|---|---|---|---|
| Array of uniform objects | User lists, product catalogs, log entries | 20-35% savings | Best use case. TOON's tabular format shines here. |
| API responses with arrays | Paginated lists, search results | 0-15% savings | Savings mainly from array portion. |
| Mixed nested structures | Complex API responses | -5% to +10% | Results vary. Test with your data. |
| Configuration objects | App settings, feature flags | -10% to -20% | TOON increases tokens. Use JSON. |
| Deeply nested objects | Recursive trees, org charts | -15% to -20% | TOON increases tokens. Use JSON. |
| Single flat objects | Simple key-value pairs | -5% to +5% | Negligible difference either way. |
Recommendation
Use TOON only for large arrays of uniform objects. For nested structures, configs, or mixed data, stick with minified JSON - it's often more token-efficient. Use the Minify button above to compare accurately.
Frequently Asked Questions
TOON (Token-Oriented Object Notation) is a compact, human-readable data format designed specifically for LLM inputs. It encodes the same data as JSON but with significantly fewer tokens by using tabular encoding for arrays and minimal syntax overhead. It provides lossless, deterministic round-trip conversion with JSON.
TOON works with any LLM that accepts text input, including Claude, GPT-4, GPT-3.5, Llama, Mistral, and others. Since LLMs process text tokens, the reduced token count directly translates to cost savings and more headroom within context windows. However, note that most LLMs were trained primarily on JSON, so you may need to include a brief format explanation in your prompts.
No. All conversion happens entirely in your browser using JavaScript. Your data never leaves your device. We don't store, log, or transmit any of the JSON or TOON content you enter. You can verify this by checking the network tab in your browser's developer tools.
We use GPT-4's tokenization algorithm (via gpt-tokenizer) for counting. This gives accurate counts for OpenAI models. Other LLMs (Claude, Llama, etc.) use different tokenizers, so actual counts may vary slightly (typically within 5-10%). The relative savings percentage is usually consistent across models.
TOON can actually INCREASE token usage for: (1) Deeply nested structures (15-20% more tokens than minified JSON), (2) Configuration objects without arrays (10-20% more tokens), (3) Highly irregular data where each object has different fields. TOON only saves tokens for uniform arrays of objects with consistent fields. Always use the Minify button to compare against real-world minified JSON - savings are much lower than when comparing to formatted JSON.
Yes. The @toon-format/toon library is available on npm and provides encode/decode functions for JavaScript/TypeScript. There are also implementations for Python, PHP, Go, Rust, and .NET. TOON is designed for lossless round-trip conversion, so you can convert to TOON for LLM calls and back to JSON for your application logic.
No. TOON is specifically optimized for LLM token efficiency, not as a general-purpose data interchange format. We recommend keeping JSON for APIs, storage, and application data, and converting to TOON only when sending data to LLMs. This gives you the best of both worlds: JSON's ubiquity and tooling, plus TOON's token efficiency where it matters.
TOON has an open specification available at github.com/toon-format/spec. The format uses indentation-based nesting, tabular encoding for uniform arrays (declaring fields once then streaming rows), minimal quoting, and explicit array length declarations. The official TypeScript implementation is at github.com/toon-format/toon.
YAML is often suggested as a token-efficient alternative to JSON, but this is misleading. Benchmarks show YAML uses ~21% MORE tokens than minified JSON because: (1) YAML can't be minified - whitespace carries meaning, (2) YAML still repeats keys for every array item, just like JSON. TOON solves both problems: it uses tabular encoding for arrays (keys declared once, then rows like CSV), resulting in ~26% fewer tokens than YAML in benchmarks. For uniform arrays, TOON beats both YAML and minified JSON.