As we build more complex AI agents and applications, Context Window limits and token costs are becoming critical constraints. Sending massive JSON blobs to models like GPT-4 or Claude 3.5 Sonnet burns through tokens rapidly due to the repetitive syntax of JSON.
The Verbosity of JSON
Consider a simple array of users. In JSON, you repeat the key names for every single object:
[
{"id": 1, "name": "Alice", "role": "admin"},
{"id": 2, "name": "Bob", "role": "user"},
{"id": 3, "name": "Charlie", "role": "user"}
]
All those quotes, brackets, and repeated keys ("id", "name", "role") add up to significant token waste, especially with thousands of records.
Enter TOON (Table Object Notation)
TOON is designed to be dense and efficient, similar to a markdown table but machine-readable. It eliminates key repetition:
| id | name | role |
|----|---------|-------|
| 1 | Alice | admin |
| 2 | Bob | user |
| 3 | Charlie | user |
For large datasets, TOON can reduce token usage by 30-50% compared to JSON, without losing the structured nature of the data. This means cheaper API calls and more room in your context window for actual instructions.
Convert Automatically
You don't need to format this manually. json2toon.co provides an instant JSON to TOON converter.
Simply paste your JSON, get the optimized TOON output, and paste that into your LLM prompt. It's a simple optimization that pays for itself immediately.
Optimize your prompts now: https://json2toon.co