Toon is a compact serialization format that encodes JSON data into a token-efficient representation optimized for use in large language model prompts.
The format addresses the problem that JSON's structural overhead consumes significant tokens when passed to LLMs, which charge by token count. Toon solves this by combining YAML-style indentation for nested objects with CSV-style tabular forms for uniform data. It automatically selects the most compact representation based on data shape: inline form for primitive arrays, tabular form for arrays of uniform objects, keyed tabular form for objects whose values are uniform objects, and list form as a fallback for mixed or non-uniform data. The encoding is lossless and reversible, functioning as a translation layer between JSON used programmatically and a more compact representation for LLM input.
Developers should choose Toon when working with LLM prompts containing structured data where token efficiency matters economically. It suits datasets with uniform objects—arrays of items with consistent fields or records keyed by ID—where it can achieve compression comparable to CSV while maintaining explicit structure. The format is less efficient for deeply nested or non-uniform data, where JSON may be preferable. The project provides a TypeScript SDK and CLI tool, allowing developers to convert existing JSON without changing their data pipeline.
The project maintains an active specification repository separate from the implementation, inviting community contribution to the format design itself. Development includes benchmarking tools that measure token savings on real data. The maintainers explicitly acknowledge the format as stable but still evolving, positioning it as collaborative rather than finalized.