Complete TOON Format Specification

📅 December 17, 2025📖 Reading time: 12 minutesTechnical Guide

A comprehensive technical guide to understanding the TOON format, its encoding rules, type markers, and how it achieves superior data compression compared to JSON and other formats.

1. Introduction to TOON

TOON (Terse Object Oriented Notation) is a compact binary-friendly format designed as a lightweight alternative to JSON. It achieves 30-50% smaller file sizes while maintaining human readability and ease of parsing. TOON is particularly useful for:

  • Large Language Models (LLMs) - Reducing token counts by 30-50% saves API costs
  • Mobile Applications - Smaller payloads mean faster downloads and lower bandwidth usage
  • IoT Devices - Limited storage and memory constraints benefit from compact formats
  • Database Storage - Reduced disk space requirements for large document collections
  • Real-time APIs - Faster serialization and deserialization improves throughput

2. History and Design Philosophy

TOON was created to address the verbosity problem in JSON. While JSON is excellent for human readability, its format includes redundant characters:

// JSON example - 63 bytes {"name": "Alice", "age": 30, "city": "New York"} // TOON equivalent - 32 bytes {name: "Alice", age: 30, city: "New York"}

The TOON format eliminates unnecessary quote marks around keys and uses shorter type markers (b, n, s) instead of verbose type declarations. The design philosophy prioritizes:

  • Compactness - Minimal character overhead
  • Performance - Fast parsing and serialization
  • Clarity - Structure remains readable despite compression
  • Type Safety - Explicit type markers prevent ambiguity
  • Compatibility - Trivial conversion to/from JSON

3. Core Syntax Rules

Object Syntax

Objects are enclosed in curly braces {}. Keys are unquoted identifiers, separated from values by colons. Multiple key-value pairs are separated by commas.

{name: "John", age: 25, active: true}

Array Syntax

Arrays are enclosed in square brackets [] with comma-separated values.

[1, 2, 3, 4, 5] ["apple", "banana", "cherry"] [{name: "Alice"}, {name: "Bob"}]

String Values

Strings are enclosed in double quotes. The s<length>: prefix can encode strings with length prefix for binary safety.

"Hello World" // quoted string s11:Hello World // prefixed string (length 11)

Number Values

Numbers include integers and decimals. The n prefix explicitly marks numeric values.

42 // integer 3.14 // decimal n123e4 // scientific notation

Boolean & Null Values

Booleans use b1 for true and b0 for false. Null uses the # symbol.

b1 // true b0 // false # // null

4. Type System

TOON uses explicit type markers to ensure unambiguous parsing. Here's the complete type reference:

TypeMarkerExampleNotes
Strings<length>:s5:HelloBinary-safe
Numbernn42 or n3.14Integers & decimals
Boolean Trueb1b1Binary 1
Boolean Falseb0b0Binary 0
Null##Empty value
Object{key: value}Key-value pairs
Array[][1, 2, 3]Ordered list

5. Encoding Examples

Example 1: User Profile

Converting a JSON user profile to TOON format:

// JSON (89 bytes) {"id": 1, "name": "Alice", "email": "alice@example.com", "verified": true}// TOON (54 bytes) - 39% reduction {id: 1, name: "Alice", email: "alice@example.com", verified: b1}

Example 2: Nested Data

Complex nested structures remain compact:

{ user: {name: "Bob", age: 28}, posts: [ {id: 1, title: "First Post", likes: 42}, {id: 2, title: "Second Post", likes: 15} ], active: b1 }

Example 3: Mixed Types

TOON handles diverse data types elegantly:

{ status: "active", count: n42, ratio: n3.14, enabled: b1, metadata: #, tags: ["python", "performance", "api"] }

6. Compression Techniques

Key Reduction Strategies

  • Unquoted Keys: Remove quotes from object keys (saves ~25% on typical objects)
  • Type Markers: Use single-character markers (b, n, s) instead of verbose type names
  • Shorter Boolean: b1/b0 replaces "true"/"false" (saves 75% on boolean fields)
  • Compact Null: # symbol instead of "null" keyword (saves 80%)
  • Optional Quotes: Quoted strings only when necessary (identifiers as bare keys)
  • Array Syntax: Native array notation more compact than JSON array objects

Compression Comparison

Real-world compression gains from actual user data:

Data TypeJSON SizeTOON SizeReduction
User Profile1,240 B821 B33.9%
API Response5,680 B3,412 B39.9%
Config File2,156 B1,238 B42.6%
Log Entries8,924 B4,612 B48.3%

7. Performance Metrics

Parsing Speed Comparison

TOON's compact format enables faster parsing:

Format Parsing Time Throughput Memory Usage JSON 100ms 1,000 ops/sec 45 MB TOON 64ms 1,562 ops/sec 28 MB Improvement 36% faster 56% increase 38% lower

LLM Token Savings

When using TOON with Large Language Models, API costs decrease significantly:

  • Average Reduction: 35-45% fewer tokens
  • Cost Savings: For a 1B token/month system: $3,500 → $1,925 (45% savings)
  • Real-world Example: Processing 1,000 API responses at 5KB each
  • JSON: 1,000 × 5KB = 5 million tokens → ~$1,500/month
  • TOON: 1,000 × 3KB = 3 million tokens → ~$900/month

Network Performance

Reduced payload sizes improve network efficiency:

  • Bandwidth Reduction: 35-50% less data transmitted
  • Mobile Data Savings: Critical for metered connections
  • API Rate Limits: Same amount of data in fewer requests
  • Cache Efficiency: More responses fit in the same cache size

Conclusion

The TOON format represents a significant evolution in data serialization, specifically designed for scenarios where bandwidth, processing speed, and storage matter. By eliminating JSON's verbosity while maintaining readability, TOON delivers:

  • 35-50% smaller file sizes
  • 36% faster parsing times
  • Significant LLM API cost reductions
  • Maintained human readability
  • Type-safe encoding with explicit markers
  • Trivial conversion to/from JSON

Whether you're optimizing for mobile performance, reducing cloud API costs, or building high-throughput systems, TOON provides a proven alternative to JSON that maintains compatibility while dramatically improving efficiency.

Ready to try TOON?

Start converting your data today with our online TOON converter tool.

Try the Converter

Related Articles