TOON for TYPO3 

Compact Β· Token-Efficient Β· Human-Readable Data Format for AI Prompts & LLM Contexts 

Version 1.0.0 License TYPO3 12,13 PHP 8.0+ AI Ready


πŸ“š Table of Contents 

  1. Overview
  2. Key Features
  3. Benchmark & Analytics
  4. Installation
  5. Configuration
  6. Usage
  7. Quick Benchmark Route
  8. Analytics & Visualization
  9. Integration Use Cases
  10. Compatibility
  11. Compression Visualization
  12. License

✨ Overview 

TOON for TYPO3 β€” also known as Token-Optimized Object Notation β€” is a TYPO3-native AI data optimization library that transforms large JSON or PHP arrays into a compact, readable, and token-efficient format.

It’s crafted for developers working with ChatGPT, Gemini, Claude, Mistral, or OpenAI APIs, helping you: βœ… Save tokens and reduce API costs βœ… Simplify complex prompt structures βœ… Improve AI response quality and context understanding βœ… Maintain human readability and reversibility


πŸš€ Key Features 

Feature Description
πŸ” Bidirectional Conversion Convert JSON ⇄ TOON with ease
🧩 Readable & Compact YAML-like structure, human-friendly format
πŸ’° Token-Efficient Save up to 70% tokens on every AI prompt
πŸ”’ Preserves Key Order Ensures deterministic data output
πŸ“Š Built-in Analytics Measure token, byte, and compression performance
🌍 AI & LLM Ready Optimized for ChatGPT, Gemini, Claude, and Mistral models
πŸ†• Complex Nested Array Support Fully supports deeply nested associative and indexed arrays

Complex & Nested Array Support 

TOON now supports deeply nested and mixed data structures, including:

  • Multi-level associative arrays
  • Indexed collections inside objects
  • Complex real-world structures like users, profiles, orders, metadata, and logs

This enhancement ensures that no structural information is lost, while still benefiting from TOON’s compact, token-efficient format.

Example: Nested Data Conversion 

$data = [
    'user' => [
        'id' => 101,
        'active' => true,
        'roles' => ['admin', 'editor'],
        'profile' => [
            'age' => 32,
            'location' => [
                'city' => 'ABC',
                'country' => 'India',
            ],
        ],
    ],
    'orders' => [
        [
            'order_id' => 'ORD-1001',
            'amount' => 1998,
            'status' => 'paid',
        ],
    ],
];

echo \RRP\T3Toon\Service\Toon::convert($data);
Copied!

This structure remains human-readable, reversible, and compact, even with deep nesting.


πŸ§ͺ Real-World Benchmark 

Metric JSON TOON Reduction
Size (bytes) 7,718 2,538 67.12% smaller
Tokens (est.) 1,930 640 ~66.8% fewer tokens

πŸ“ˆ Visual Comparison 

JSON (7.7 KB)
β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ

TOON (2.5 KB)
β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ
Copied!

πŸ’‘ TOON reduces token load by 60–75%, improving AI efficiency, cost, and response quality.


βš™οΈ Installation 

composer require rrp/t3-toon
Copied!

βš™οΈ Configuration 


🧠 Usage 

➀ Convert JSON β†’ TOON 

$data = [
    'user' => 'ABC',
    'message' => 'Hello, how are you?',
    'tasks' => [
        ['id' => 1, 'done' => false],
        ['id' => 2, 'done' => true],
    ],
];

$converted = \RRP\T3Toon\Service\Toon::convert($data);
echo $converted;
Copied!

Output:

user: ABC
message: Hello\, how are you?
tasks:
  items[2]{done,id}:
    false,1
    true,2
Copied!

➀ Convert TOON β†’ JSON 

$toon = <<<TOON
user: ABC
tasks:
  items[2]{id,done}:
    1,false
    2,true
TOON;

$json = \RRP\T3Toon\Service\Toon::decode($toon);
print_r($json);
Copied!

➀ Estimate Tokens 

$stats = Toon::estimateTokens($converted);
print_r($stats);
Copied!

Output:

{
  "words": 20,
  "chars": 182,
  "tokens_estimate": 19
}
Copied!

πŸ“Š Analytics & Visualization 

Metric Description Example
json_size_bytes Original JSON size 7,718
toon_size_bytes Optimized TOON size 2,538
saving_percent Space saved 67.12%
tokens_estimate Estimated token count 640
compression_ratio Ratio (TOON/JSON) 0.33

🧠 Visual Graph (Efficiency Comparison)

| JSON: β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ 100%
| TOON: β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ 33%
Copied!

🧩 Integration Use Cases 

Use Case Benefit
πŸ€– AI Prompt Engineering Compress structured data for LLMs
πŸ“‰ Token Optimization Reduce token usage and API costs
🧠 Data Preprocessing Streamline complex structured inputs
🧾 Logging & Debugging Store compact, readable structured logs
πŸ—„οΈ Database Storage Optimization Reduce JSON storage size while preserving structure
πŸ” Developer Tools Perfect for previews and compact dashboards

🧰 Compatibility 

TYPO3 PHP Package Version
12.x – 13.x β‰₯ 8 v1.0.0

πŸ“‰ Example Compression Visualization 

JSON (7.7 KB)
β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ

TOON (2.5 KB)
β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ
Copied!

🧠 ~67% size reduction while retaining complete data accuracy.


πŸ’‘ Contribution 

Contributions are highly encouraged!

  • Fork the repository
  • Create a new feature branch
  • Commit & push improvements
  • Submit a Pull Request πŸŽ‰

πŸ“œ License 

Licensed under the MIT License β€” free for both commercial and personal use.


Made with 🧑 for TYPO3 community