CBOR (Concise Binary Object Representation),TOON (Token-Oriented Object Notation), andJSON (JavaScript Object Notation) serve different optimization goals: CBOR prioritizes binary efficiency for bandwidth-constrained environments, TOON optimizes for token count in AI/LLM applications, and JSON provides universal human readability.
This comparison analyzes all three formats across multiple dimensions: file size, parsing performance, token efficiency, data type support, and ecosystem maturity. Each format excels in specific use cases, and understanding these trade-offs enables optimal format selection for your application requirements.
Test conversions between formats using our tools: JSON to CBOR,JSON to TOON,CBOR to JSON, andTOON to JSON.
Quick Comparison Overview
| Feature | JSON | CBOR | TOON |
|---|---|---|---|
| Encoding Type | Text (UTF-8) | Binary | Text (Compact) |
| Human Readable | ✓ Yes | ✗ No | ✓ Yes |
| File Size | Baseline (100%) | 50-80% of JSON | 40-60% of JSON |
| Token Count | Baseline (100%) | N/A (binary) | ~50% of JSON |
| Parsing Speed | Moderate | 2-3x faster | ~1.5x faster |
| Data Types | 6 basic types | 20+ types | 6 basic types |
| Binary Data | Base64 required | Native support | Base64 required |
| Browser Support | Native | Requires library | Requires library |
| Standardization | ECMA-404 | RFC 8949 | Community |
| Best Use Case | Web APIs | IoT, Mobile | AI/LLM Apps |
Size Comparison: Real-World Data
Comparing the same sensor data encoded in all three formats:
Example 1: IoT Sensor Reading (5 fields)
JSON
87 bytes{
"temp": 22.5,
"humidity": 65,
"pressure": 1013.25,
"device": "sensor-01",
"active": true
}CBOR (Hex)
52 bytesA5 64 74 65 6D 70 F9 41 68 68 68 75 6D 69 64 69 74 79 18 41 68 70 72 65 73 73 75 72 65 F9 ...
TOON
48 bytestemp:22.5 humidity:65 pressure:1013.25 device:sensor-01 active:true
JSON
87 bytes (100%)
CBOR
52 bytes (60%)
40% savings
TOON
48 bytes (55%)
45% savings
Example 2: Array of 100 Sensor Records
JSON
8,532 bytes
Baseline
CBOR
4,276 bytes
50% smaller than JSON
TOON
3,850 bytes
55% smaller than JSON
Annual Bandwidth Analysis (10,000 devices, 1,000 messages/day)
JSON
Daily: 85 GB
Annual: 31.1 TB
CBOR
Daily: 42.5 GB
Annual: 15.5 TB
Saves 15.6 TB/year
TOON
Daily: 38.3 GB
Annual: 14.0 TB
Saves 17.1 TB/year
Token Efficiency for AI/LLM Applications
When using data with Large Language Models (GPT-4, Claude, Gemini), token count directly impacts API costs.TOON is specifically designed to minimize token usage, while CBOR's binary nature makes it unsuitable for text-based LLM prompts. You can convert your JSON data to TOON format using our JSON to TOON converter or format existing TOON data with the TOON formatter.
100 Customer Records: Token Count & Cost Analysis
JSON Format
Token Count: 2,841 tokens
GPT-4 Cost (input): $0.028
Claude Cost (input): $0.023
TOON Format
Token Count: 1,420 tokens
GPT-4 Cost (input): $0.014
Claude Cost (input): $0.012
50% cost reduction
Note: CBOR is binary and cannot be used directly in LLM prompts. For AI applications requiring human-readable data with minimal tokens, TOON is the optimal choice. Test your data with our TOON to JSON converter andTOON validator.
Annual LLM API Cost Projection
Application making 10,000 LLM API calls per day with 100-record datasets:
Using JSON
Daily API Cost: $280
Monthly: $8,400
Annual: $102,200
Using TOON
Daily API Cost: $140
Monthly: $4,200
Annual: $51,100
Saves $51,100/year
Performance Benchmarks
Parsing and serialization performance for 1,000 records on Node.js 20 (lower is better):
Parsing Speed (Decode)
Serialization Speed (Encode)
Benchmark Environment: Node.js 20.10, cbor-x 1.5.9, standard JSON.parse/stringify. TOON parsing uses custom optimized parser. Results may vary by implementation and data structure.
Which Format Should You Use?
The choice between JSON, CBOR, and TOON depends on your specific constraints and priorities. Here's what works best in different scenarios:
JSON: Best for Web APIs and General Use
JSON remains the default choice for most web applications. Every programming language has built-in JSON support, and developers can read and debug it without special tools. If you're building a public API, JSON is usually the right choice because it maximizes compatibility with client libraries and doesn't require additional dependencies.
Common use cases:
- • REST APIs consumed by web and mobile clients
- • Configuration files that humans need to edit (package.json, tsconfig.json)
- • Small payloads where the size difference doesn't matter
- • Development and debugging (easy to inspect in browser DevTools)
- • Third-party integrations and webhooks
CBOR: Best for Bandwidth-Constrained Environments
CBOR makes sense when you're sending large amounts of data frequently and bandwidth or battery life is a concern. IoT devices benefit significantly because CBOR uses 40-50% less bandwidth than JSON. It's also required by certain standards like WebAuthn for authentication. The tradeoff is that you need a CBOR library and can't easily inspect the binary data.
Common use cases:
- • IoT devices where battery life and cellular data costs matter
- • Mobile apps on metered connections
- • High-frequency telemetry (thousands of messages per second)
- • WebAuthn authentication (required by the standard)
- • Internal microservices where bandwidth savings add up
- • Binary data like images or encrypted content (avoids base64 overhead)
TOON: Best for AI and LLM Applications
TOON is specifically designed for applications using Large Language Models like GPT-4 or Claude. When you pay per token, reducing token count by 50% directly cuts your API costs in half. TOON removes JSON's verbose syntax (quotes, braces, colons) while remaining human-readable. Use our JSON to TOON converter andTOON formatter to test your data.
Common use cases:
- • Sending data to GPT-4, Claude, or Gemini APIs (minimize token costs)
- • RAG systems where you need to fit more context in the prompt
- • Chatbots maintaining conversation history within token limits
- • Batch processing large datasets through AI models
- • Prompt engineering where every token counts
Hybrid Architecture Strategies
Production systems often use multiple formats optimized for different layers:
Strategy 1: Public JSON + Internal CBOR
Use JSON for public-facing APIs (developer experience) and CBOR for internal microservice communication (performance).
Example: REST API returns JSON, but backend services communicate via CBOR over message queues.
Strategy 2: JSON Storage + TOON for LLM
Store data as JSON (queryable, debuggable) but convert to TOON when sending to AI models (cost savings).
Example: Customer records in JSON database, converted to TOON before sending to GPT-4 for analysis.
Strategy 3: Multi-Format API with Content Negotiation
Support multiple formats via Accept header (application/json, application/cbor, application/toon). Clients choose based on their needs.
Example: Web clients use JSON, mobile apps use CBOR, AI applications use TOON.
Strategy 4: CBOR for IoT Edge + TOON for Cloud AI
IoT devices send CBOR (minimal bandwidth), edge gateway converts to TOON for cloud-based AI processing (token optimization).
Example: Smart sensors → CBOR → Edge gateway → TOON → Cloud AI analysis.
Format Conversion Tools
Test and convert between all three formats:
Technical Specifications & Resources
- •RFC 8949: CBOR Specification - Official IETF standard for CBOR binary encoding
- •ECMA-404: JSON Standard - Official JSON data interchange format specification
- •CBOR.io - Official CBOR website with implementations and documentation
- •JSON.org - Introducing JSON by Douglas Crockford
- •TOON GitHub Repository - Official TOON format specification and libraries
- •W3C WebAuthn Standard - Web authentication using CBOR for credential data
- •OpenAI Tokenizer - Test token counts for different formats with GPT models
- •MDN: JSON Documentation - Comprehensive JSON reference from Mozilla
- •CBOR GitHub Organization - Reference implementations in multiple languages
- •What is CBOR? - Introduction to CBOR binary format
- •What is TOON? - Introduction to token-optimized TOON format
- •CBOR vs JSON Comparison - Detailed two-way format comparison
- •TOON to Table Converter - Visualize TOON data as HTML tables
- •CSV to TOON Converter - Optimize CSV data for AI/LLM applications
- •TOON Validator Tool - Validate TOON syntax and format