# TOON for TYPO3
### Compact Β· Token-Efficient Β· Human-Readable Data Format for AI Prompts & LLM Contexts
---
## π Table of Contents
1. [Overview](#-overview)
2. [Key Features](#-key-features)
3. [Benchmark & Analytics](#-real-world-benchmark)
4. [Installation](#-installation)
5. [Configuration](#-configuration)
6. [Usage](#-usage)
7. [Quick Benchmark Route](#-quick-benchmark-route)
8. [Analytics & Visualization](#-analytics--visualization)
10. [Integration Use Cases](#-integration-use-cases)
11. [Compatibility](#-compatibility)
12. [Compression Visualization](#-example-compression-visualization)
14. [License](#-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
```php
$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);
```
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)
βββββββββββββββββ
```
π‘ **TOON** reduces token load by _60β75%_, improving **AI efficiency**, **cost**, and **response quality**.
---
## βοΈ Installation
```bash
composer require rrp/t3-toon
```
---
## βοΈ Configuration
---
## π§ Usage
### β€ Convert JSON β TOON
```php
$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;
```
**Output:**
```
user: ABC
message: Hello\, how are you?
tasks:
items[2]{done,id}:
false,1
true,2
```
---
### β€ Convert TOON β JSON
```php
$toon = <<
Made with π§‘ for TYPO3 community