A compact, LLM-optimized representation of JSON data. Token-Oriented Object Notation is a compact, human-readable encoding of the JSON data model that minimizes tokens and makes structure easy for models to follow. It's intended for LLM input as a drop-in, lossless representation of your existing JSON.
Token-Oriented Object Notation (TOON) is a streamlined, human-friendly format that expresses the full JSON data model using far fewer tokens. It merges the indentation style of YAML with the compact, tabular structure of CSV, producing a format that is easy for humans to read and highly effective for Large Language Models (LLMs) to process.
TOON is designed as a drop-in, lossless alternative to JSON in environments where token usage, clarity, and structural predictability matter.
Modern AI systems can handle large inputs, but token cost remains significant. JSON, although widely used, often consumes more tokens than necessary. TOON aims to solve this by providing:
- More compact schema representation
- Clear array structures with declared sizes
- A predictable layout that reduces LLM parsing errors
- Efficient tabular formatting for uniform object arrays
The result is a format that mirrors JSON's structure but is considerably lighter and more model-friendly.
{
"context": {
"task": "Cafes we visited last winter",
"location": "Delhi",
"season": "winter_2024"
},
"friends": ["rahul", "meera", "tanya"],
"hikes": [
{
"id": 1,
"name": "Brew Garden",
"distanceKm": 2.3,
"elevationGain": 0,
"companion": "rahul",
"wasSunny": false
},
{
"id": 2,
"name": "Coffee Street",
"distanceKm": 1.1,
"elevationGain": 0,
"companion": "meera",
"wasSunny": true
},
{
"id": 3,
"name": "Mocha Corner",
"distanceKm": 3.0,
"elevationGain": 10,
"companion": "tanya",
"wasSunny": true
}
]
}context:
task: Cafes we visited last winter
location: Delhi
season: winter_2024
friends[3]: rahul,meera,tanya
hikes[3]{id,name,distanceKm,elevationGain,companion,wasSunny}:
1,Brew Garden,2.3,0,rahul,false
2,Coffee Street,1.1,0,meera,true
3,Mocha Corner,3,10,tanya,true
TOON offers significant token savings when compared to equivalent JSON structures.
Benchmark results show:
- ~40% reduction in token usage across mixed datasets
- Higher parsing accuracy with LLMs β TOON averaged ~74%, while JSON scored around 70%
This improvement comes from TOON's compact structure and reduced syntactic noise.
TOON maintains a perfect one-to-one relationship with JSON. Every TOON file can be converted back into JSON:
- Without losing any fields or values
- Preserving all objects, arrays, and primitive data types
- Ensuring deterministic and reversible encoding
TOON includes structural hints that make it easier for LLMs to parse and reconstruct data reliably:
- Array length declarations (e.g.,
family[3]) - Field headers for uniform object arrays (
{id,name,...}) - Indentation-driven nesting similar to YAML
These built-in cues reduce ambiguity and improve model performance.
The syntax avoids unnecessary punctuation such as excessive brackets or quotes.
This balance provides:
- YAML-like readability
- CSV-like compactness
- Cleaner and more predictable formatting
TOON handles uniform arrays of objects exceptionally well.
Such arrays are represented in a table-like row format, resulting in:
- Less repetition
- Reduced token usage
- Cleaner structure for machine processing
TOON is supported across multiple languages, with active or upcoming implementations for:
- TypeScript / JavaScript
- Python
- Go
- Rust
- .NET
- Additional languages in development
This multi-language ecosystem ensures TOON can integrate into various pipelines and workflows.
Although TOON is powerful, some cases benefit more from JSON or CSV:
Highly nested or irregular data structures can sometimes be more compact and straightforward in JSON format.
If array items have inconsistent fields, TOON's tabular format becomes less effective.
CSV remains more minimal for pure, flat, spreadsheet-like data.
TOON adds lightweight structural markers (like array lengths and field headers) that slightly increase size compared to raw CSV.
In performance-critical or on-device environments (e.g., local/quantized LLMs like Ollama):
- JSON may parse faster despite its verbosity
- It's recommended to benchmark both formats for:
- TTFT (Time To First Token)
- Tokens per second
- Total response time
Try TOON instantly with npx:
# Convert JSON to TOON
npx @toon-format/cli input.json -o output.toon
# Pipe from stdin
echo '{"name": "Tushar", "role": "sde"}' | npx @toon-format/cliSee the CLI section for all options and examples.
# npm
npm install @toon-format/toon
# pnpm
pnpm add @toon-format/toon
# yarn
yarn add @toon-format/toonExample usage:
import { encode } from '@toon-format/toon'
const data = {
users: [
{ id: 1, name: 'john', role: 'admin' },
{ id: 2, name: 'Doe', role: 'user' }
]
}
console.log(encode(data))
// users[2]{id,name,role}:
// 1,john,admin
// 2,Doe,userExperiment with TOON format interactively using these community-built tools for token comparison, format conversion, and validation:
- Format Tokenization Playground
- TOON Tools
Command-line tool for quick JSONβTOON conversions, token analysis, and pipeline integration. Auto-detects format from file extension, supports stdin/stdout workflows, and offers delimiter options for maximum efficiency.
# Encode JSON to TOON (auto-detected)
npx @toon-format/cli input.json -o output.toon
# Decode TOON to JSON (auto-detected)
npx @toon-format/cli data.toon -o output.json
# Pipe from stdin (no argument needed)
cat data.json | npx @toon-format/cli
echo '{"name": "Tushar"}' | npx @toon-format/cli
# Output to stdout
npx @toon-format/cli input.json
# Show token savings
npx @toon-format/cli data.json --statsTip: See the full CLI documentation for all options, examples, and advanced usage.
Detailed syntax references, implementation guides, and quick lookups for understanding and using the TOON format.
- Format Overview β Complete syntax documentation
- Syntax Cheatsheet β Quick reference
- API Reference β Encode/decode usage (TypeScript)
TOON works best when you show the format instead of describing it. The structure is self-documenting β models parse it naturally once they see the pattern. Wrap data in ````toon` code blocks for input, and show the expected header template when asking models to generate TOON. Use tab delimiters for even better token efficiency.
Follow the detailed LLM integration guide for strategies, examples, and validation techniques.
Comprehensive guides, references, and resources to help you get the most out of the TOON format and tools.
- Introduction & Installation β What TOON is, when to use it, first steps
- Format Overview β Complete syntax with examples
- Benchmarks β Accuracy & token efficiency results
- CLI β Command-line tool for JSONβTOON conversions
- Using TOON with LLMs β Prompting strategies & validation
- Playgrounds β Interactive tools
- API Reference β TypeScript/JavaScript encode/decode API
- Syntax Cheatsheet β Quick format lookup
- Specification v2.0 β Normative rules for implementers
Contributions are welcome! Please feel free to submit issues, feature requests, or pull requests.
TOON - Making AI data interchange more efficient, one token at a time.