TOON (Token-Oriented Object Notation) is presented as a token-saving alternative to JSON, but its actual benefits are often overstated in marketing. The claimed 50% savings usually compare TOON to pretty-printed JSON, not the minified JSON used in real-world LLM applications. When compared to minified JSON, TOON offers significant savings, up to 35%, specifically for large, uniform arrays of objects. However, TOON can actually increase token usage by 10-20% for configuration objects and deeply nested structures due to its reliance on whitespace and repeated key declarations. TOON's efficiency stems from declaring field names once for uniform arrays and then listing values, akin to CSV rows. For non-tabular data, its YAML-like indentation becomes more verbose than minified JSON because whitespace and repeated keys still consume tokens. Plain CSV is the most token-efficient format for purely tabular data without any hierarchy, outperforming TOON by about 30%. YAML is generally the least efficient format for token usage. Developers should measure actual token savings with their specific data payloads rather than relying on general claims. Factors like LLM training data bias, lack of standardization, debugging complexity, and penalties for mixed data structures are important considerations. TOON is a valuable tool for specific use cases like large uniform arrays, but minified JSON remains the best choice for nested objects, configurations, and mixed data structures. Intelligent format selection based on data characteristics is key, with TOON for uniform arrays, CSV for flat tables, and minified JSON for other scenarios.
dev.to
dev.to
Create attached notes ...
