Download the PHP package fontebasso/json-to-toon without Composer
On this page you can find all versions of the php package fontebasso/json-to-toon. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download fontebasso/json-to-toon
More information about fontebasso/json-to-toon
Files in fontebasso/json-to-toon
Package json-to-toon
Short Description json-to-toon converts verbose JSON into a lightweight, LLM-friendly “Toon” format — optimized for ChatGPT and other AI models to cut token usage, boost context efficiency, and keep responses sharp.
License MIT
Informations about the package json-to-toon
json-to-toon
json-to-toon is a lightweight PHP library that converts verbose JSON into a compact, LLM-optimized format called TOON.
The TOON format preserves structure while minimizing token usage, improving context efficiency for large language models such as ChatGPT and Claude.
This implementation follows the TOON Specification v2.0, supporting arrays, nested objects, primitives, and non-uniform structures — including compact representation of associative and nested data.
Installation
You can install the library via Composer:
Overview
Traditional JSON structures are often verbose and redundant, especially when serialized for language models.
json-to-toon introduces a concise syntax that encodes data in a tabular form, preserving semantics while reducing size.
Example
Input JSON:
Converted Toon:
This representation is shorter, token-efficient, and ideal for transmitting structured context to LLMs such as ChatGPT or Claude.
Usage
From PHP Array
From JSON String
Output
Compact Mode
json-to-toon automatically encodes associative objects using the compact TOON syntax:
Output
Nested arrays are represented recursively:
Tests
Run the PHPUnit suite:
Open the generated coverage report at:
Continuous Integration
The repository includes a GitHub Actions workflow that automatically runs tests on PHP 8.2, 8.3, and 8.4 for every push or pull request to main.
License
This library is licensed under the MIT License. See the LICENSE file for details.