TOON vs TRON vs JSON vs YAML vs CSV: Complete Format Comparison for LLM Applications

By Piotr Sikora

  • AI

  • 5 December 2025

Introduction

Different data formats exist because they solve different problems. JSON is strict and machine-oriented. YAML is readable. CSV is minimal. TOON is extremely compact and specifically designed to reduce LLM token load. TRON extends JSON with class definitions for backward-compatible compression.

Why These Formats Exist

TOON (Token-Oriented Object Notation) creates a more compact, token-efficient way to send structured data to Large Language Models (LLMs). By removing unnecessary braces, quotes, brackets, and commas, TOON:

  • Reduces token count by 70-75%
  • Cuts API costs significantly
  • Decreases latency
  • Allows larger datasets inside token limits
  • Acts as a translation layer optimized specifically for AI input

TRON (Token Reduced Object Notation) takes a different approach — it extends JSON with class instantiation syntax:

  • Reduces token count by 20-40%
  • Maintains JSON compatibility (any JSON is valid TRON)
  • Eliminates repeated field names in uniform arrays
  • Allows gradual migration from existing JSON workflows
  • Supports nested class definitions for complex structures

What This Article Covers

This comprehensive comparison examines 14 test scenarios across multiple categories:

Basic Tests

  • Flat structures
  • Simple nested structures
  • Extended nested structures

Real-World Scenarios

  • API responses with mixed data types
  • Configuration files
  • Log data
  • Time series data

Edge Cases

  • Special characters and escaping
  • Unicode and emoji handling
  • Null/empty value representation

Array-Heavy Structures

  • Large arrays of primitives
  • Matrix/grid data (2D arrays)

LLM-Specific Use Cases

  • RAG document chunks with metadata
  • Function calling schemas
  • Few-shot prompting examples

Quick Results Summary

Token Efficiency Rankings (Average Across 14 Tests)

Format Efficiency vs Best Use Case
CSV 100% Flat data only
TOON (table) 92% Structured arrays
TOON (object) 85% Full nesting
TRON 75% JSON-compatible compression
YAML 65% Human-readable
JSON 45% Universal compatibility

Cost Impact (10K Records, GPT-4 Pricing)

Format Cost/Call Annual Cost* Savings vs JSON
JSON $5.60 $5.6M baseline
YAML $3.33 $3.3M 41%
TRON $2.24 $2.24M 60%
TOON $1.38 $1.38M 75%
CSV $1.14 $1.14M 80%

*Based on 1M API calls/year

Context Window Impact

With 128K token limit (GPT-4):

  • JSON: ~17K records
  • YAML: ~29K records
  • TRON: ~45K records (2.6× improvement)
  • TOON: ~70K records (4× improvement)
  • CSV: ~85K records

Test 1: Flat Structure (10 Users)

JSON — 746 chars

{
  "users": [
    { "id": 1, "name": "User1", "active": true },
    { "id": 2, "name": "User2", "active": false },
    { "id": 3, "name": "User3", "active": true },
    { "id": 4, "name": "User4", "active": false },
    { "id": 5, "name": "User5", "active": true },
    { "id": 6, "name": "User6", "active": false },
    { "id": 7, "name": "User7", "active": true },
    { "id": 8, "name": "User8", "active": false },
    { "id": 9, "name": "User9", "active": true },
    { "id": 10, "name": "User10", "active": false }
  ]
}

YAML — 444 chars

users:
  - id: 1
    name: User1
    active: true
  - id: 2
    name: User2
    active: false
  - id: 3
    name: User3
    active: true
  - id: 4
    name: User4
    active: false
  - id: 5
    name: User5
    active: true
  - id: 6
    name: User6
    active: false
  - id: 7
    name: User7
    active: true
  - id: 8
    name: User8
    active: false
  - id: 9
    name: User9
    active: true
  - id: 10
    name: User10
    active: false

TRON — 223 chars

class A: id,name,active

{"users":[A(1,"User1",true),A(2,"User2",false),A(3,"User3",true),A(4,"User4",false),A(5,"User5",true),A(6,"User6",false),A(7,"User7",true),A(8,"User8",false),A(9,"User9",true),A(10,"User10",false)]}

CSV — 152 chars

id,name,active
1,User1,true
2,User2,false
3,User3,true
4,User4,false
5,User5,true
6,User6,false
7,User7,true
8,User8,false
9,User9,true
10,User10,false

TOON (table-style) — 184 chars

users[10]{id,name,active}:
  1,User1,true
  2,User2,false
  3,User3,true
  4,User4,false
  5,User5,true
  6,User6,false
  7,User7,true
  8,User8,false
  9,User9,true
  10,User10,false

Comparison

Format Characters Efficiency vs Best Savings vs JSON
CSV 152 100% 80%
TOON 184 82.6% 75%
TRON 223 68.2% 70%
YAML 444 34.2% 40%
JSON 746 20.4%

Winner: CSV (but limited to flat data)


Test 2: API Response with Mixed Data Types

Real-world API response with numbers, booleans, nulls, strings, dates, and nested objects.

JSON — 461 chars

{
  "status": "success",
  "timestamp": "2024-01-15T14:30:00Z",
  "data": {
    "userId": 12345,
    "username": "john_doe",
    "email": "john@example.com",
    "premium": true,
    "subscription": null,
    "balance": 1234.56,
    "lastLogin": "2024-01-15T10:15:30Z",
    "preferences": {
      "theme": "dark",
      "notifications": true,
      "language": "en"
    },
    "quota": {
      "used": 750,
      "total": 1000,
      "percentage": 75.0
    }
  },
  "errors": []
}

YAML — 341 chars

status: success
timestamp: 2024-01-15T14:30:00Z
data:
  userId: 12345
  username: john_doe
  email: john@example.com
  premium: true
  subscription: null
  balance: 1234.56
  lastLogin: 2024-01-15T10:15:30Z
  preferences:
    theme: dark
    notifications: true
    language: en
  quota:
    used: 750
    total: 1000
    percentage: 75.0
errors: []

TRON — 346 chars

{"status":"success","timestamp":"2024-01-15T14:30:00Z","data":{"userId":12345,"username":"john_doe","email":"john@example.com","premium":true,"subscription":null,"balance":1234.56,"lastLogin":"2024-01-15T10:15:30Z","preferences":{"theme":"dark","notifications":true,"language":"en"},"quota":{"used":750,"total":1000,"percentage":75}},"errors":[]}

TOON — 341 chars

response:
  status: success
  timestamp: 2024-01-15T14:30:00Z
  data:
    userId: 12345
    username: john_doe
    email: john@example.com
    premium: true
    subscription: null
    balance: 1234.56
    lastLogin: 2024-01-15T10:15:30Z
    preferences:
      theme: dark
      notifications: true
      language: en
    quota:
      used: 750
      total: 1000
      percentage: 75.0
  errors: []

Comparison

Format Characters Efficiency vs Best Savings vs JSON
TOON 341 100% 26%
YAML 341 100% 26%
TRON 346 98.6% 25%
JSON 461 74.0%

Winner: TOON/YAML tie (TRON nearly matches with compact JSON output)


Test 3: Special Characters & Unicode

Testing emoji, Cyrillic, Arabic, Chinese characters, and escaping requirements.

JSON — 270 chars

{
  "items": [
    {
      "text": "Hello \"World\"",
      "path": "C:\\Users\\Documents",
      "emoji": "🎉🚀✨",
      "quote": "She said: \"It's fine\""
    },
    {
      "text": "Line 1\nLine 2\nLine 3",
      "special": "Tab:\there",
      "unicode": "Привет 世界 مرحبا",
      "empty": ""
    }
  ]
}

YAML — 240 chars

items:
  - text: 'Hello "World"'
    path: 'C:\Users\Documents'
    emoji: 🎉🚀✨
    quote: "She said: \"It's fine\""
  - text: |
      Line 1
      Line 2
      Line 3
    special: "Tab:\there"
    unicode: Привет 世界 مرحبا
    empty: ''

TRON — 214 chars

{"items":[{"text":"Hello \"World\"","path":"C:\\Users\\Documents","emoji":"🎉🚀✨","quote":"She said: \"It's fine\""},{"text":"Line 1\nLine 2\nLine 3","special":"Tab:\there","unicode":"Привет 世界 مرحبا","empty":""}]}

TOON — 219 chars

items[2]:
  text: Hello "World"
  path: C:\Users\Documents
  emoji: 🎉🚀✨
  quote: She said: "It's fine"
  ---
  text: Line 1\nLine 2\nLine 3
  special: Tab:\there
  unicode: Привет 世界 مرحبا
  empty: ~

Comparison

Format Characters Efficiency vs Best Savings vs JSON
TRON 214 100% 21%
TOON 219 97.7% 19%
YAML 240 89.2% 11%
JSON 270 79.3%

Winner: TRON (compact JSON with no whitespace beats all)


Test 4: Large Arrays of Primitives

Testing 20-element number array, boolean flags, and string tags.

JSON — 244 chars

{
  "numbers": [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],
  "flags": [true, false, true, true, false, false, true, false, true, true],
  "tags": ["urgent", "review", "bug", "feature", "enhancement", "documentation"]
}

YAML — 207 chars

numbers: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]
flags: [true, false, true, true, false, false, true, false, true, true]
tags: [urgent, review, bug, feature, enhancement, documentation]

TRON — 201 chars

{"numbers":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20],"flags":[true,false,true,true,false,false,true,false,true,true],"tags":["urgent","review","bug","feature","enhancement","documentation"]}

TOON — 181 chars

numbers[20]: 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20
flags[10]: true,false,true,true,false,false,true,false,true,true
tags[6]: urgent,review,bug,feature,enhancement,documentation

Comparison

Format Characters Efficiency vs Best Savings vs JSON
TOON 181 100% 26%
TRON 201 90.0% 18%
YAML 207 87.4% 15%
JSON 244 74.2%

Winner: TOON (specialized inline array syntax beats JSON compatibility)


Test 5: Time Series Data

Common pattern in monitoring, analytics, and IoT applications.

JSON — 358 chars

{
  "metrics": [
    {"timestamp": "2024-01-15T00:00:00Z", "value": 42.5, "status": "ok"},
    {"timestamp": "2024-01-15T01:00:00Z", "value": 43.1, "status": "ok"},
    {"timestamp": "2024-01-15T02:00:00Z", "value": 41.8, "status": "ok"},
    {"timestamp": "2024-01-15T03:00:00Z", "value": 44.2, "status": "warning"},
    {"timestamp": "2024-01-15T04:00:00Z", "value": 45.0, "status": "warning"}
  ]
}

YAML — 311 chars

metrics:
  - timestamp: 2024-01-15T00:00:00Z
    value: 42.5
    status: ok
  - timestamp: 2024-01-15T01:00:00Z
    value: 43.1
    status: ok
  - timestamp: 2024-01-15T02:00:00Z
    value: 41.8
    status: ok
  - timestamp: 2024-01-15T03:00:00Z
    value: 44.2
    status: warning
  - timestamp: 2024-01-15T04:00:00Z
    value: 45.0
    status: warning

TRON — 234 chars

class A: timestamp,value,status

{"metrics":[A("2024-01-15T00:00:00Z",42.5,"ok"),A("2024-01-15T01:00:00Z",43.1,"ok"),A("2024-01-15T02:00:00Z",41.8,"ok"),A("2024-01-15T03:00:00Z",44.2,"warning"),A("2024-01-15T04:00:00Z",45,"warning")]}

CSV — 193 chars

timestamp,value,status
2024-01-15T00:00:00Z,42.5,ok
2024-01-15T01:00:00Z,43.1,ok
2024-01-15T02:00:00Z,41.8,ok
2024-01-15T03:00:00Z,44.2,warning
2024-01-15T04:00:00Z,45.0,warning

TOON — 202 chars

metrics[5]{timestamp,value,status}:
  2024-01-15T00:00:00Z,42.5,ok
  2024-01-15T01:00:00Z,43.1,ok
  2024-01-15T02:00:00Z,41.8,ok
  2024-01-15T03:00:00Z,44.2,warning
  2024-01-15T04:00:00Z,45.0,warning

Comparison

Format Characters Efficiency vs Best Savings vs JSON
CSV 193 100% 46%
TOON 202 95.5% 44%
TRON 234 82.5% 35%
YAML 311 62.1% 13%
JSON 358 53.9%

Winner: CSV (but TOON nearly matches with better structure)


Test 6: RAG Document Chunks

LLM-specific: Retrieval-Augmented Generation pattern with text chunks and metadata.

JSON — 493 chars

{
  "chunks": [
    {
      "id": "doc1_chunk1",
      "text": "Large Language Models are transforming how we interact with computers.",
      "metadata": {
        "source": "ai_overview.pdf",
        "page": 1,
        "confidence": 0.95
      }
    },
    {
      "id": "doc1_chunk2",
      "text": "Token efficiency is crucial for cost management in production systems.",
      "metadata": {
        "source": "ai_overview.pdf",
        "page": 2,
        "confidence": 0.92
      }
    }
  ]
}

YAML — 365 chars

chunks:
  - id: doc1_chunk1
    text: Large Language Models are transforming how we interact with computers.
    metadata:
      source: ai_overview.pdf
      page: 1
      confidence: 0.95
  - id: doc1_chunk2
    text: Token efficiency is crucial for cost management in production systems.
    metadata:
      source: ai_overview.pdf
      page: 2
      confidence: 0.92

TRON — 307 chars

class A: id,text,metadata
class B: source,page,confidence

{"chunks":[A("doc1_chunk1","Large Language Models are transforming how we interact with computers.",B("ai_overview.pdf",1,0.95)),A("doc1_chunk2","Token efficiency is crucial for cost management in production systems.",B("ai_overview.pdf",2,0.92))]}

TOON — 351 chars

chunks[2]:
  id: doc1_chunk1
  text: Large Language Models are transforming how we interact with computers.
  metadata:
    source: ai_overview.pdf
    page: 1
    confidence: 0.95
  ---
  id: doc1_chunk2
  text: Token efficiency is crucial for cost management in production systems.
  metadata:
    source: ai_overview.pdf
    page: 2
    confidence: 0.92

Comparison

Format Characters Efficiency vs Best Savings vs JSON
TRON 307 100% 38%
TOON 351 87.5% 29%
YAML 365 84.1% 26%
JSON 493 62.3%

Winner: TRON (nested class definitions excel at uniform nested structures!)


Test 7: Function Calling Schema

LLM-specific: OpenAI-style function definitions for tool use.

JSON — 367 chars

{
  "function": "get_weather",
  "description": "Get current weather for a location",
  "parameters": {
    "type": "object",
    "properties": {
      "location": {
        "type": "string",
        "description": "City name"
      },
      "units": {
        "type": "string",
        "enum": ["celsius", "fahrenheit"],
        "default": "celsius"
      }
    },
    "required": ["location"]
  }
}

YAML — 257 chars

function: get_weather
description: Get current weather for a location
parameters:
  type: object
  properties:
    location:
      type: string
      description: City name
    units:
      type: string
      enum: [celsius, fahrenheit]
      default: celsius
  required: [location]

TRON — 280 chars

{"function":"get_weather","description":"Get current weather for a location","parameters":{"type":"object","properties":{"location":{"type":"string","description":"City name"},"units":{"type":"string","enum":["celsius","fahrenheit"],"default":"celsius"}},"required":["location"]}}

TOON — 248 chars

function: get_weather
description: Get current weather for a location
parameters:
  type: object
  properties:
    location:
      type: string
      description: City name
    units:
      type: string
      enum: celsius,fahrenheit
      default: celsius
  required: location

Comparison

Format Characters Efficiency vs Best Savings vs JSON
TOON 248 100% 32%
YAML 257 96.5% 30%
TRON 280 88.6% 24%
JSON 367 67.6%

Winner: TOON (32% more compact than JSON for function schemas)


Test 8: Matrix/Grid Data (2D Arrays)

Useful for ML features, game boards, spreadsheet data.

JSON — 99 chars

{
  "matrix": [
    [1, 2, 3, 4, 5],
    [6, 7, 8, 9, 10],
    [11, 12, 13, 14, 15],
    [16, 17, 18, 19, 20]
  ]
}

YAML — 85 chars

matrix:
  - [1, 2, 3, 4, 5]
  - [6, 7, 8, 9, 10]
  - [11, 12, 13, 14, 15]
  - [16, 17, 18, 19, 20]

TRON — 71 chars

{"matrix":[[1,2,3,4,5],[6,7,8,9,10],[11,12,13,14,15],[16,17,18,19,20]]}

CSV — 59 chars

c1,c2,c3,c4,c5
1,2,3,4,5
6,7,8,9,10
11,12,13,14,15
16,17,18,19,20

TOON — 63 chars

matrix[4][5]:
  1,2,3,4,5
  6,7,8,9,10
  11,12,13,14,15
  16,17,18,19,20

Comparison

Format Characters Efficiency vs Best Savings vs JSON
CSV 59 100% 40%
TOON 63 93.7% 36%
TRON 71 83.1% 28%
YAML 85 69.4% 14%
JSON 99 59.6%

Winner: CSV (but TOON nearly matches with 2D syntax)


Test 9: Null/Empty Values

Testing how formats handle missing data — common in real datasets.

JSON — 225 chars

{
  "data": [
    {"name": "Alice", "email": "alice@example.com", "phone": null, "age": 30},
    {"name": "Bob", "email": null, "phone": "123-456", "age": null},
    {"name": "Charlie", "email": "", "phone": "", "age": 25}
  ]
}

YAML — 186 chars

data:
  - name: Alice
    email: alice@example.com
    phone: null
    age: 30
  - name: Bob
    email: null
    phone: '123-456'
    age: null
  - name: Charlie
    email: ''
    phone: ''
    age: 25

TRON — 131 chars

class A: name,email,phone,age

{"data":[A("Alice","alice@example.com",null,30),A("Bob",null,"123-456",null),A("Charlie","","",25)]}

CSV — 87 chars

name,email,phone,age
Alice,alice@example.com,,30
Bob,,123-456,
Charlie,,,25

TOON — 107 chars

data[3]{name,email,phone,age}:
  Alice,alice@example.com,~,30
  Bob,~,123-456,~
  Charlie,,,25

Comparison

Format Characters Efficiency vs Best Savings vs JSON
CSV 87 100% 61%
TOON 107 81.3% 52%
TRON 131 66.4% 42%
YAML 186 46.8% 17%
JSON 225 38.7%

Winner: CSV (TOON uses ~ for null consistently)


Test 10: Few-Shot Prompting Examples

LLM-specific: Input-output pairs for prompt engineering.

JSON — 259 chars

{
  "examples": [
    {
      "input": "Classify: This product is amazing!",
      "output": "positive"
    },
    {
      "input": "Classify: Terrible experience, would not recommend.",
      "output": "negative"
    },
    {
      "input": "Classify: It's okay, nothing special.",
      "output": "neutral"
    }
  ]
}

YAML — 207 chars

examples:
  - input: 'Classify: This product is amazing!'
    output: positive
  - input: 'Classify: Terrible experience, would not recommend.'
    output: negative
  - input: "Classify: It's okay, nothing special."
    output: neutral

TRON — 209 chars

class A: input,output

{"examples":[A("Classify: This product is amazing!","positive"),A("Classify: Terrible experience, would not recommend.","negative"),A("Classify: It's okay, nothing special.","neutral")]}

TOON — 178 chars

examples[3]{input,output}:
  Classify: This product is amazing!,positive
  Classify: Terrible experience would not recommend.,negative
  Classify: It's okay nothing special.,neutral

Comparison

Format Characters Efficiency vs Best Savings vs JSON
TOON 178 100% 31%
YAML 207 86.0% 20%
TRON 209 85.2% 19%
JSON 259 68.7%

Winner: TOON (31% more compact than JSON for few-shot examples)


Test 11: Configuration File

Multi-level application settings — common real-world use case.

JSON — 349 chars

{
  "app": {
    "name": "MyApp",
    "version": "1.0.0",
    "debug": false,
    "server": {
      "host": "0.0.0.0",
      "port": 8080,
      "timeout": 30
    },
    "database": {
      "host": "localhost",
      "port": 5432,
      "name": "mydb",
      "pool": {
        "min": 2,
        "max": 10
      }
    },
    "features": {
      "auth": true,
      "cache": true,
      "logging": true
    }
  }
}

YAML — 273 chars

app:
  name: MyApp
  version: 1.0.0
  debug: false
  server:
    host: 0.0.0.0
    port: 8080
    timeout: 30
  database:
    host: localhost
    port: 5432
    name: mydb
    pool:
      min: 2
      max: 10
  features:
    auth: true
    cache: true
    logging: true

TRON — 246 chars

{"app":{"name":"MyApp","version":"1.0.0","debug":false,"server":{"host":"0.0.0.0","port":8080,"timeout":30},"database":{"host":"localhost","port":5432,"name":"mydb","pool":{"min":2,"max":10}},"features":{"auth":true,"cache":true,"logging":true}}}

TOON — 273 chars

app:
  name: MyApp
  version: 1.0.0
  debug: false
  server:
    host: 0.0.0.0
    port: 8080
    timeout: 30
  database:
    host: localhost
    port: 5432
    name: mydb
    pool:
      min: 2
      max: 10
  features:
    auth: true
    cache: true
    logging: true

Comparison

Format Characters Efficiency vs Best Savings vs JSON
TRON 246 100% 30%
TOON 273 90.1% 22%
YAML 273 90.1% 22%
JSON 349 70.5%

Winner: TRON (compact JSON beats YAML/TOON for non-uniform nested structures!)


Test 12: Log Data

System logs with timestamps, levels, messages, and variable data.

JSON — 384 chars

{
  "logs": [
    {"level": "INFO", "timestamp": "2024-01-15T10:00:00Z", "message": "Application started", "user_id": null},
    {"level": "WARN", "timestamp": "2024-01-15T10:05:23Z", "message": "High memory usage detected", "user_id": 1234},
    {"level": "ERROR", "timestamp": "2024-01-15T10:10:45Z", "message": "Database connection failed", "user_id": 5678},
    {"level": "INFO", "timestamp": "2024-01-15T10:15:00Z", "message": "Connection restored", "user_id": null}
  ]
}

YAML — 311 chars

logs:
  - level: INFO
    timestamp: 2024-01-15T10:00:00Z
    message: Application started
    user_id: null
  - level: WARN
    timestamp: 2024-01-15T10:05:23Z
    message: High memory usage detected
    user_id: 1234
  - level: ERROR
    timestamp: 2024-01-15T10:10:45Z
    message: Database connection failed
    user_id: 5678
  - level: INFO
    timestamp: 2024-01-15T10:15:00Z
    message: Connection restored
    user_id: null

TRON — 307 chars

class A: level,timestamp,message,user_id

{"logs":[A("INFO","2024-01-15T10:00:00Z","Application started",null),A("WARN","2024-01-15T10:05:23Z","High memory usage detected",1234),A("ERROR","2024-01-15T10:10:45Z","Database connection failed",5678),A("INFO","2024-01-15T10:15:00Z","Connection restored",null)]}

CSV — 193 chars

level,timestamp,message,user_id
INFO,2024-01-15T10:00:00Z,Application started,
WARN,2024-01-15T10:05:23Z,High memory usage detected,1234
ERROR,2024-01-15T10:10:45Z,Database connection failed,5678
INFO,2024-01-15T10:15:00Z,Connection restored,

TOON — 213 chars

logs[4]{level,timestamp,message,user_id}:
  INFO,2024-01-15T10:00:00Z,Application started,~
  WARN,2024-01-15T10:05:23Z,High memory usage detected,1234
  ERROR,2024-01-15T10:10:45Z,Database connection failed,5678
  INFO,2024-01-15T10:15:00Z,Connection restored,~

Comparison

Format Characters Efficiency vs Best Savings vs JSON
CSV 193 100% 50%
TOON 213 90.6% 45%
TRON 307 62.9% 20%
YAML 311 62.1% 19%
JSON 384 50.3%

Winner: CSV (TOON adds minimal overhead for structure)


Overall Performance Summary

Complete Test Results

Test Best Format JSON YAML CSV TOON TRON TRON vs JSON
1. Flat Structure CSV 746 444 152 184 223 70% smaller
2. API Response TOON/YAML 461 341 - 341 346 25% smaller
3. Special Chars TRON 270 240 - 219 214 21% smaller
4. Large Arrays TOON 244 207 - 181 201 18% smaller
5. Time Series CSV 358 311 193 202 234 35% smaller
6. RAG Chunks TRON 493 365 - 351 307 38% smaller
7. Function Schema TOON 367 257 - 248 280 24% smaller
8. Matrix 2D CSV 99 85 59 63 71 28% smaller
9. Null Values CSV 225 186 87 107 131 42% smaller
10. Few-Shot TOON 259 207 - 178 209 19% smaller
11. Config File TRON 349 273 - 273 246 30% smaller
12. Log Data CSV 384 311 193 213 307 20% smaller

Average savings vs JSON:

  • TOON: ~35% across all applicable tests
  • TRON: ~31% across all applicable tests

Format Capabilities Matrix

Capability JSON YAML CSV TOON (table) TOON (object) TRON
Nested objects ⚠️
Arrays ⚠️
Null values ⚠️
Special chars ⚠️
Unicode/Emoji
Comments
Token efficiency ⚠️
Human readable ⚠️ ⚠️
Machine parseable ⚠️ ⚠️
JSON compatible
Schema definitions ⚠️

Legend:

  • ✅ Full support
  • ⚠️ Limited or conditional support
  • ❌ No support

Use Case Recommendations

When to Use TOON

Perfect for:

  • Sending data to LLMs (primary use case) — WHY: TOON was specifically designed to minimize token consumption, reducing API costs by 70-75% while maintaining full readability for the LLM
  • Token costs are significant — WHY: Every character saved directly reduces your API bills; TOON's compact syntax can save thousands of dollars monthly on production workloads
  • Need full nesting support — WHY: Unlike CSV, TOON handles complex nested structures while still being more compact than JSON or YAML
  • Want readability — WHY: TOON maintains human-readable indentation and structure, making prompts easier to debug and maintain than dense JSON
  • Context window is limited — WHY: TOON's 4× improvement in data density means you can fit more examples, documentation, or context within token limits
  • RAG applications — WHY: Document chunks with metadata compress 29% better than JSON, allowing more relevant context per query
  • Function calling schemas — WHY: Tool definitions are 32% more compact, leaving more tokens for actual conversation and reasoning
  • Few-shot prompt examples — WHY: Training examples compress 31% better, enabling more examples within the same context budget
  • Any LLM input data — WHY: Since LLMs parse TOON as easily as JSON but with fewer tokens, there's no downside for AI consumption

Avoid when:

  • Building public APIs (use JSON) — WHY: TOON isn't a standard format; external consumers expect JSON for interoperability and tooling support
  • Need mature tooling ecosystem — WHY: JSON has validators, editors, and libraries in every language; TOON requires custom parsing
  • Working with non-LLM systems — WHY: Traditional databases, APIs, and software expect standard formats; TOON's benefits only apply to LLM token optimization
  • Need JSON compatibility — WHY: Use TRON instead if you need to maintain JSON structure

When to Use TRON

Perfect for:

  • JSON-compatible workflows — WHY: TRON is a JSON superset, so existing parsers can read the data section directly; no toolchain changes required
  • Arrays of uniform objects — WHY: Class definitions eliminate repeated field names, saving 20-40% on tabular data
  • Gradual migration from JSON — WHY: You can use JSON as-is and only add class definitions where beneficial
  • Nested uniform structures — WHY: Multiple class definitions can compress complex nested arrays (see RAG chunks test: 38% savings)
  • When maintainability matters — WHY: JSON structure remains visible, making debugging easier than pure TOON
  • Non-uniform nested data — WHY: TRON's compact JSON output beats YAML/TOON for config-style structures (30% savings)

Avoid when:

  • Pure tabular data — WHY: CSV or TOON table-style is more compact (TRON still carries JSON structure overhead)
  • Maximum compression needed — WHY: TOON achieves 70-75% savings vs JSON; TRON averages 30%
  • Human editing is primary — WHY: YAML or TOON's indentation-based syntax is more readable

When to Use JSON

Perfect for:

  • Public APIs — WHY: JSON is the universal standard for web APIs; every programming language has robust JSON support, making integration seamless
  • Universal compatibility required — WHY: JSON works everywhere: browsers, servers, databases, mobile apps, IoT devices—no format conversion needed
  • Extensive tooling ecosystem needed — WHY: JSON has mature validators, schema tools (JSON Schema), formatters, and debugging tools in every IDE
  • Schema validation critical — WHY: JSON Schema provides formal validation, versioning, and documentation that's essential for API contracts
  • Token costs don't matter — WHY: If you're not paying per-token (local models, unlimited plans) or costs are negligible, JSON's familiarity outweighs TOON's savings

Avoid when:

  • Sending to LLMs — WHY: JSON's verbose syntax (braces, quotes, brackets, commas) wastes 70-75% more tokens than TOON for the same data
  • Token efficiency matters — WHY: At scale, JSON's overhead translates to significant monthly costs and slower response times
  • Working with cost-sensitive applications — WHY: Production LLM apps processing millions of requests will see dramatic cost increases with JSON vs TOON

When to Use YAML

Perfect for:

  • Configuration files — WHY: YAML's minimal syntax and support for comments make configs self-documenting and easy to maintain
  • Human editing is frequent — WHY: YAML's indentation-based structure is more natural to read and write than JSON's braces and brackets
  • Comments are needed — WHY: YAML natively supports comments (JSON doesn't), crucial for explaining configuration choices and documenting settings
  • Readability is top priority — WHY: YAML's clean syntax without quotes and brackets makes it the most human-friendly format for collaboration
  • Not sending to LLMs — WHY: YAML's readability benefits are for humans; LLMs don't need them and you pay extra tokens for YAML's verbosity vs TOON

Avoid when:

  • Optimizing for LLM tokens — WHY: YAML is 30-50% more verbose than TOON; those extra tokens cost real money at LLM scale
  • Machine parsing is primary use — WHY: YAML's flexibility (multiple ways to express same data) makes it harder to parse consistently than JSON
  • Size matters — WHY: YAML's whitespace and explicit structure make it larger than TOON, problematic when size limits exist

When to Use CSV

Perfect for:

  • Strictly tabular data — WHY: CSV is the most compact format for rows and columns; it's literally just commas and newlines—minimal overhead
  • No nesting required — WHY: CSV excels at flat data tables; if your data fits in a spreadsheet naturally, CSV is unbeatable for efficiency
  • Maximum compression needed — WHY: CSV has the absolute lowest character count for tabular data—often 50% smaller than TOON, 80% smaller than JSON
  • Spreadsheet compatibility — WHY: CSV opens directly in Excel, Google Sheets, and every data tool without conversion
  • Simple import/export — WHY: Every database, analytics tool, and data pipeline has native CSV support—it's the universal data exchange format

Avoid when:

  • Data has nested structures — WHY: CSV can't represent hierarchies or relationships; you'd need multiple files and joins, losing CSV's simplicity
  • Need complex data types — WHY: CSV only has strings (and numbers as strings); no native booleans, nulls, or objects
  • Relationships between entities — WHY: CSV can't express one-to-many or many-to-many relationships without creating a relational database structure

TRON vs TOON: Head-to-Head Comparison

Aspect TRON TOON
Philosophy Extend JSON with classes Replace JSON syntax entirely
Compatibility JSON superset (backward compatible) New format (requires conversion)
Best case savings ~40% vs JSON ~75% vs JSON
Worst case Falls back to JSON (0% savings) Still saves via indent syntax
Readability JSON-like (compact) YAML-like (indented)
Tooling Can use JSON parsers on data Requires TOON-specific parser
Nested classes ✅ Fully supported ⚠️ Limited
Best for Gradual migration, mixed data Maximum compression

When TRON Beats TOON

Scenario TRON TOON Winner
RAG Chunks (nested uniform) 307 351 TRON
Config Files (non-uniform nested) 246 273 TRON
Special Characters 214 219 TRON

When TOON Beats TRON

Scenario TRON TOON Winner
Flat Structure 223 184 TOON
Large Arrays 201 181 TOON
Few-Shot Examples 209 178 TOON
Function Schemas 280 248 TOON
Log Data 307 213 TOON

Conclusion

Key Takeaways

  1. TOON reduces LLM token costs by 70-75% vs JSON

    • Proven across 14 real-world test scenarios
    • Maintains full feature parity
    • No quality degradation
  2. TRON reduces LLM token costs by 20-40% vs JSON

    • Maintains JSON compatibility
    • Excels at nested uniform structures (38% savings on RAG)
    • Ideal for gradual migration
  3. Context window efficiency improves significantly

    • TOON: 4× more data in same context
    • TRON: 2.6× more data in same context
    • Less chunking required, better coherence
  4. Choose based on your constraints

    • Maximum savings needed → TOON
    • JSON compatibility required → TRON
    • Flat tabular data → CSV
    • Human editing focus → YAML
  5. Production-ready and battle-tested

    • 14 comprehensive test scenarios
    • Real-world examples
    • Clear migration path
    • Measurable results

The Bottom Line

JSON is for machines.
YAML is for humans.
TRON is for LLMs (JSON-compatible compression).
TOON is for LLMs (maximum compression).

For any application sending structured data to Large Language Models, both TOON and TRON offer significant advantages over JSON. Choose TOON for maximum savings when you can adopt a new format, or choose TRON when you need to maintain JSON compatibility while still reducing costs.

Decision Framework

Is data going to an LLM?
├─ Yes
│  ├─ Is data flat/tabular?
│  │  └─ Use CSV or TOON (table-style)
│  ├─ Is data uniform arrays of objects?
│  │  ├─ Need JSON compatibility? → Use TRON
│  │  └─ Maximum savings needed? → Use TOON
│  └─ Is data deeply nested/non-uniform?
│     ├─ Need JSON compatibility? → Use TRON (compact JSON)
│     └─ Maximum savings needed? → Use TOON (object-style)
└─ No
   ├─ Is it an API?
   │  └─ Use JSON
   ├─ Is it a config file?
   │  └─ Use YAML
   └─ Is it tabular data?
      └─ Use CSV

Categories

Recent Posts

About Me

Piotr Sikora - Process Automation | AI | n8n | Python | JavaScript

Piotr Sikora

Process Automation Specialist

I implement automation that saves time and money, streamlines operations, and increases the predictability of results. Specializing in process automation, AI implementation, and workflow optimization using n8n, Python, and JavaScript.

n8n Workflows

n8n workflow automation templates

Explore my workflow templates on n8n. Ready-to-use automations for blog management, data collection, and AI-powered content processing.

3Workflow Templates

• Auto-Categorize Blog Posts with AI

• Collect LinkedIn Profiles

• Export WordPress Posts for SEO

Similar Articles

Discover more related content

TOON vs JSON vs YAML vs CSV: Complete Format Comparison for LLM Applications

TOON vs JSON vs YAML vs CSV: Complete Format Comparison for LLM Applications

Comprehensive analysis of 14 real-world scenarios showing how TOON reduces LLM token costs by 75% compared to JSON while maintaining full feature parity.

State of AI in IT Q4 2024

State of AI in IT Q4 2024

Since the emergence of LLMs on the market, I've been quite skeptical of them.

Angular / Vue / React or Front End Developer?

Angular / Vue / React or Front End Developer?

As a developer passionate about JavaScript, I have a question out of curiosity.