PHPackages                             rrp/t3-toon - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Parsing &amp; Serialization](/categories/parsing)
4. /
5. rrp/t3-toon

ActiveTypo3-cms-extension[Parsing &amp; Serialization](/categories/parsing)

rrp/t3-toon
===========

TOON for TYPO3 — Spec-compliant TOON for TYPO3: token-efficient AI data format with JSON ⇄ TOON conversion for LLMs and AI agents.

4.0.0(2w ago)6121[2 PRs](https://github.com/therohanparmar/t3-toon/pulls)MITPHPPHP ^8.1CI passing

Since Jan 11Pushed 2w ago1 watchersCompare

[ Source](https://github.com/therohanparmar/t3-toon)[ Packagist](https://packagist.org/packages/rrp/t3-toon)[ Docs](https://github.com/therohanparmar/t3-toon)[ RSS](/packages/rrp-t3-toon/feed)WikiDiscussions main Synced today

READMEChangelog (8)Dependencies (9)Versions (12)Used By (0)

TOON for TYPO3
==============

[](#toon-for-typo3)

### Token-Optimized Object Notation for AI &amp; LLM Workflows

[](#token-optimized-object-notation-for-ai--llm-workflows)

 [![Version 4.0.0](https://camo.githubusercontent.com/4df5d9320f9834b61fad3b4f326202d22effe607efbc279ac5030de95474f035/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f56657273696f6e2d342e302e302d626c7565)](https://camo.githubusercontent.com/4df5d9320f9834b61fad3b4f326202d22effe607efbc279ac5030de95474f035/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f56657273696f6e2d342e302e302d626c7565) [![License](https://camo.githubusercontent.com/c9ad4c1219adfefc13416e563e4713017f74a69aeea833b48029ca9e02462e1c/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f746865726f68616e7061726d61722f74332d746f6f6e)](https://camo.githubusercontent.com/c9ad4c1219adfefc13416e563e4713017f74a69aeea833b48029ca9e02462e1c/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f746865726f68616e7061726d61722f74332d746f6f6e) [![TYPO3 12-14](https://camo.githubusercontent.com/4c7208bd71ebde6684d40d3df6051091a414b02cdbcfa7e9798938a9eed67fba/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5459504f332d31322c31332c31342d6f72616e6765)](https://camo.githubusercontent.com/4c7208bd71ebde6684d40d3df6051091a414b02cdbcfa7e9798938a9eed67fba/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5459504f332d31322c31332c31342d6f72616e6765) [![PHP 8.1+](https://camo.githubusercontent.com/163b8f41b0cbea37929cd1c6ed0273e701d3e50b0f87b754af4f1b1211b847fb/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d382e312532422d726564)](https://camo.githubusercontent.com/163b8f41b0cbea37929cd1c6ed0273e701d3e50b0f87b754af4f1b1211b847fb/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d382e312532422d726564) [![](https://camo.githubusercontent.com/18968c6e3123cb8542b79787a50d027911f64914aed022170dc7657f5b7d844b/68747470733a2f2f6261646765732e63726f7764696e2e6e65742f7479706f332d657874656e73696f6e2d7272707433746f6f6e2f6c6f63616c697a65642e737667)](https://crowdin.com/project/typo3-extension-rrpt3toon "Crowdin")

---

> **v4.0 — now fully spec-compliant.** This release implements the official [TOON Specification v3.3](https://github.com/toon-format/spec) and passes the complete language-agnostic conformance suite (389/389 encode + decode fixtures). See [Specification compliance](#-specification-compliance) below. v4.0 is a breaking change from the 3.x custom format — review the migration notes before upgrading.

✨ What is TOON?
---------------

[](#-what-is-toon)

**TOON (Token-Oriented Object Notation)** is a **compact, human-readable, token-efficient** text format for the JSON data model, purpose-built for **AI prompts and LLM contexts**. This extension is a spec-compliant TOON encoder/decoder for TYPO3.

It helps you:

- 🔻 Reduce token usage (up to 60–75%)
- 💰 Lower AI API costs
- 🧠 Improve prompt clarity and context understanding
- 🔁 Convert data seamlessly between **JSON ⇄ TOON**

---

🚀 Key Features
--------------

[](#-key-features)

- 🔁 Bidirectional conversion (JSON ⇄ TOON)
- 🧩 Compact, YAML-like and human-readable format
- 💰 Significant token and size reduction
- 📊 Built-in analytics and token estimation
- 🧠 Optimized for ChatGPT, Gemini, Claude, and Mistral
- 🆕 Supports deeply nested and complex data structures
- 🔒 Preserves key order and data integrity
- 🗂️ Usage logs backend module — every encode/convert call is recorded with input size, output size, and optimization %, filterable and bulk-deletable

---

📦 Installation
--------------

[](#-installation)

### ➤ TYPO3 Extension Repository (TER)

[](#-typo3-extension-repository-ter)

Install via the TYPO3 backend or directly from TER:

🔗 [https://extensions.typo3.org/extension/rrp\_t3toon](https://extensions.typo3.org/extension/rrp_t3toon)

---

### ➤ Composer (Packagist)

[](#-composer-packagist)

Recommended for Composer-based TYPO3 projects: 🔗

```
composer require rrp/t3-toon
```

🧠 Quick Usage Example
---------------------

[](#-quick-usage-example)

**Static API (convenience, no DI):**

```
use RRP\T3Toon\Service\Toon;

$data = ['user' => 'ABC', 'tasks' => [['id' => 1, 'done' => false], ['id' => 2, 'done' => true]]];
echo Toon::encodeStatic($data);
// or: Toon::convertStatic($data);

$decoded = Toon::decodeStatic($toonString);
$estimate = Toon::estimateTokensStatic($toonString);
```

**Instance API (recommended in TYPO3 for dependency injection):**

```
use RRP\T3Toon\Service\Toon;
use TYPO3\CMS\Core\Utility\GeneralUtility;

$toon = GeneralUtility::makeInstance(Toon::class);
echo $toon->convert($data);
$decoded = $toon->decode($toonString);
```

**Output (TOON):**

```
user: ABC
tasks[2]{id,done}:
  1,false
  2,true

```

### Configuration options

[](#configuration-options)

Override encoding/decoding per call with **EncodeOptions** and **DecodeOptions** (null = use extension config from Install Tool):

```
use RRP\T3Toon\Domain\Model\EncodeOptions;
use RRP\T3Toon\Domain\Model\DecodeOptions;
use RRP\T3Toon\Service\Toon;

// Encoding: indent, delimiter (comma/tab/pipe), key folding
$compact = Toon::encodeStatic($data, EncodeOptions::compact());   // indent 2, comma
$readable = Toon::encodeStatic($data, EncodeOptions::readable()); // indent 4
$tabular = Toon::encodeStatic($data, EncodeOptions::tabular());   // tab delimiter
$folded = Toon::encodeStatic($data, EncodeOptions::folded());     // safe key folding
$custom = Toon::encodeStatic($data, new EncodeOptions(indent: 2, delimiter: "|", keyFolding: "safe"));

// Decoding: strict (default) vs lenient; optional dotted-key path expansion
$data = Toon::decodeStatic($toon);
$lenient = Toon::decodeStatic($toon, DecodeOptions::lenient());   // relax strict-mode checks
$expanded = Toon::decodeStatic($toon, DecodeOptions::expanded()); // expand a.b.c into nested objects
```

Extension config (Install Tool → Settings → Extension Configuration → rrp\_t3toon) provides defaults:

KeyValuesDefaultApplies to`enabled`bool`1`encode (passthrough when off)`indent`int ≥ 1`2`encode`delimiter`comma / tab / pipe`comma`encode`key_folding`off / safe`safe`encode (§13.4)`flatten_depth`int (`-1` = unbounded)`2`encode (key folding)`strict`bool`1`decode (§14)`expand_paths`off / safe`off`decode (§13.4)`show_default_example`bool`1`Playground (prefill sample on first load)**Note on `enabled`:** when this flag is turned off, `Toon::encode()` and `Toon::convert()` short-circuit and return the input as-is (string verbatim, or `json_encode($input)` for arrays/objects). This lets you toggle optimization globally without code changes. Calls are still logged so you can see in the Logs module which requests ran with optimization on vs off.

### Global helpers

[](#global-helpers)

When the extension is loaded, these global functions are available (no `use` needed):

```
toon($value);                    // encode (alias for Toon::encodeStatic)
toon_decode($toon);              // decode
toon_compact($value);            // encode with EncodeOptions::compact()
toon_readable($value);           // encode with EncodeOptions::readable()
toon_decode_lenient($toon);      // decode in non-strict mode (relaxed validation)
toon_estimate_tokens($toon);      // return ['words' => …, 'chars' => …, 'tokens_estimate' => …]
```

### Fluid ViewHelpers

[](#fluid-viewhelpers)

In Fluid templates, add the namespace and use:

```

    …

  {stats.tokens_estimate}

```

### Backend modules

[](#backend-modules)

#### Tools → TOON Playground

[](#tools--toon-playground)

Encode and decode TOON in the browser:

- Paste **JSON** and click **Encode to TOON** or **Encode (compact)** to get TOON output.
- Paste **TOON** and click **Decode from TOON** to get JSON (strict by default; optional lenient mode).
- Adjust **delimiter**, **indent**, **key folding**, and **flatten depth** like the [official playground](https://toonformat.dev/playground.html).
- Load **Hikes** or **TYPO3** example presets; char counts and size reduction vs pretty JSON are shown after encode.
- On first load the **Hikes** example is pre-filled (same as [toonformat.dev](https://toonformat.dev/playground.html)). Disable with `show_default_example` in extension settings; **Clear all** empties both fields.
- Estimated tokens and error messages are shown when relevant.

#### TOON Logs (View Logs button)

[](#toon-logs-view-logs-button)

The Logs screen is part of the same module — open it with the **View Logs** button in the Playground header (and **Back to Playground** to return); there is no separate menu entry.

Every successful `encode` / `convert` call (from anywhere — Playground, ViewHelpers, helper functions, programmatic API, scheduler tasks, CLI commands) is recorded in `tx_rrpt3toon_log`. The screen lists those rows with:

- Filters: date range, optimization status (enabled/disabled), minimum optimization %, page size.
- Per-row optimization badge (green when bytes were saved, neutral when passthrough).
- Per-row delete + bulk delete (checkbox each row + select-all in the header).
- Sliding-window pagination, newest entries first.

The schema must be migrated once after installation:

```
vendor/bin/typo3 database:updateschema "*.add,*.change"
```

For development / demos a CLI seed command is available:

```
vendor/bin/typo3 t3toon:seed-logs 500    # insert 500 random rows spread over the last 30 days
vendor/bin/typo3 t3toon:seed-logs 100 7  # 100 rows over the last 7 days
```

### Error handling

[](#error-handling)

Decoding malformed TOON throws `RRP\T3Toon\Exception\ToonDecodeException` with line number and snippet:

```
use RRP\T3Toon\Exception\ToonDecodeException;
use RRP\T3Toon\Service\Toon;

try {
    $data = Toon::decodeStatic($input);
} catch (ToonDecodeException $e) {
    // $e->getLineNumber(), $e->getSnippet()
}
```

---

📚 Documentation
---------------

[](#-documentation)

Full documentation, configuration, and advanced usage are available here:

🔗

---

🧩 Use Cases
-----------

[](#-use-cases)

- 🤖 AI prompt engineering
- 📉 Token and cost optimization
- 🧠 Structured data preprocessing
- 🧾 Compact logging and debugging
- 🗄️ Optimized JSON storage
- 🔍 Developer tooling and previews

---

🧰 Compatibility
---------------

[](#-compatibility)

TYPO3PHPExtension VersionTOON Spec12.x – 14.x≥ 8.1v4.0.0v3.3✅ Specification compliance
--------------------------

[](#-specification-compliance)

As of **v4.0.0**, this extension implements the official **[TOON Specification v3.3](https://github.com/toon-format/spec)** and passes the complete language-agnostic conformance suite — **389/389 fixtures** (153 encode + 236 decode), covering primitives, objects, primitive/tabular/nested/mixed arrays, all three delimiters (comma, tab, pipe), quoting and escaping rules, canonical number formatting, root-form detection, strict-mode validation errors, blank-line and indentation rules, key folding, and path expansion.

The vendored fixtures live in `Tests/Fixtures/spec/` (see `PROVENANCE.txt` for the pinned spec commit). Run them with:

```
php Tests/run-conformance.php          # standalone runner, no dependencies
# or, with the dev dependencies installed:
composer test:unit                     # includes the PHPUnit ConformanceTest
```

The spec engine lives in `Classes/Spec/` (`Encoder`, `Decoder`) and is dependency-free; the TYPO3 service layer (`Toon`, `ToonEncoder`, `ToonDecoder`) is a thin adapter over it.

### Upgrading from 3.x (breaking changes)

[](#upgrading-from-3x-breaking-changes)

v3.x emitted a TYPO3-specific “TOON-inspired” format. v4.0 emits **standards-compliant TOON**, so output bytes differ. Notable changes:

- Tabular arrays use the real key (`users[2]{id,name}:`) instead of a hardcoded `items[…]` wrapper.
- Object keys are preserved verbatim (no lowercasing/stripping); strings are quoted/escaped per spec instead of being trimmed.
- Primitive arrays are inline by default (`tags[3]: a,b,c`); `null` encodes as `null`.
- Removed config keys: `escape_style`, `min_rows_to_tabular`, `max_preview_items`, `coerce_scalar_types`, `primitive_array_header`. New keys: `key_folding`, `flatten_depth`, `strict`, `expand_paths`.
- `DecodeOptions::lenient()` / the `lenient` ViewHelper argument now mean **non-strict decoding** (not “skip type coercion”). `Toon::decode()` now returns `mixed` (root scalars/arrays are supported), with objects still decoded to associative arrays.

---

👨‍💻 Authors
-----------

[](#‍-authors)

- **[Rohan Parmar](https://www.linkedin.com/in/rohanrparmar)**
- **[Himanshu Ramavat](https://www.linkedin.com/in/himanshu-ramavat/)**

---

💡 Contributing
--------------

[](#-contributing)

Contributions are welcome and appreciated ❤️

- Fork the repository
- Create a feature branch
- Commit your changes
- Submit a Pull Request

---

📜 License
---------

[](#-license)

Licensed under the MIT License — free for personal and commercial use.

---

 **Made with 🧡 for the TYPO3 Developer**

###  Health Score

43

—

FairBetter than 89% of packages

Maintenance95

Actively maintained with recent releases

Popularity11

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity49

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 62.3% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~22 days

Recently: every ~35 days

Total

8

Last Release

18d ago

Major Versions

1.3.0 → 2.0.02026-02-25

2.0.0 → 3.0.02026-05-29

3.1.0 → 4.0.02026-06-15

PHP version history (3 changes)1.0.0PHP &gt;=8

1.3.0PHP ^7.4 || ^8.0

2.0.0PHP ^8.1

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/285399581?v=4)[rohan-parmar](/maintainers/rohan-parmar)[@rohan-parmar](https://github.com/rohan-parmar)

![](https://avatars.githubusercontent.com/u/77565273?v=4)[Himanshu Ramavat](/maintainers/himanshuramavat)[@himanshuramavat](https://github.com/himanshuramavat)

---

Top Contributors

[![himanshuramavat](https://avatars.githubusercontent.com/u/77565273?v=4)](https://github.com/himanshuramavat "himanshuramavat (33 commits)")[![therohanparmar](https://avatars.githubusercontent.com/u/72159621?v=4)](https://github.com/therohanparmar "therohanparmar (20 commits)")

---

Tags

aiai-promptclaudedata-formatterjsonmistralopenaiphpphp8promptprompt-compressionprompt-engineeringprompt-optimizertokentoken-optimizationtoontypo3typo3-aitypo3-ai-extensiontypo3-toonphpjsonserializationtypo3encoderdecoderllmtoontoken-efficienttypo3-cms-extensiontoon-formattoken-oriented-object-notation

###  Code Quality

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/rrp-t3-toon/health.svg)

```
[![Health](https://phpackages.com/badges/rrp-t3-toon/health.svg)](https://phpackages.com/packages/rrp-t3-toon)
```

###  Alternatives

[sbsaga/toon

🧠 TOON for Laravel — a compact, human-readable, and token-efficient data format for AI prompts &amp; LLM contexts. Perfect for ChatGPT, Gemini, Claude, Mistral, and OpenAI integrations (JSON ⇄ TOON).

6753.8k](/packages/sbsaga-toon)[friendsoftypo3/headless

This extension provides way to output content from TYPO3 in JSON format.

176325.9k19](/packages/friendsoftypo3-headless)[friendsoftypo3/headless_news

This extension provides integration with news to output content from TYPO3 in JSON format.

1158.4k](/packages/friendsoftypo3-headless-news)[suin/json

A Simple wrapper of json\_decode() and json\_encode(). This provides object-oriented interface and exception-based error handing.

1027.6k3](/packages/suin-json)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
