Author: EFT Repo: dify-plugin-toon Version: 1.0.0 Type: tool
This Dify plugin converts data between JSON and TOON (Token-Oriented Object Notation), a compact, human-readable serialization format designed for LLM prompts. By removing redundant quotes, braces and repeated keys, TOON typically reduces token usage by 30-60% compared to JSON, which lowers cost and leaves more context window for actual content.
Conversion is powered by toon-format,
the official Python implementation of the TOON specification. It passes
every official conformance fixture and guarantees lossless round-trips
(loads(dumps(data)) == data) for every JSON-compatible value, including
nested structures and tabular arrays with nested field groups.
- TOON specification: https://github.com/toon-format/spec
- Related plugin request: langgenius/dify-plugins#1619
- Dify 1.14.2 or later
No network connection or external service is required: conversion runs locally in the plugin runtime, with no endpoint to configure and no credentials to provide.
- From Dify Marketplace: search "TOON" in the Plugins page and install.
- Or install from a local
.difypkg: Plugins -> Install Plugin -> Via Local File.
Convert a JSON string into TOON format.
| Parameter | Type | Required | Description |
|---|---|---|---|
json_input |
string |
Yes |
The JSON string to convert |
delimiter |
select |
No |
Field delimiter: comma (default), tab or pipe |
Outputs:
- text: the plain TOON text, ready for the LLM to read directly.
- json: a structured object with the TOON text and compression statistics, referenceable from downstream nodes:
| Field | Description |
|---|---|
toon |
The converted TOON string |
original_chars |
Character count of the input JSON |
toon_chars |
Character count of the TOON output |
compression_ratio |
Saved fraction, e.g. 0.6 means 60% smaller |
savings_percent |
Same value as percentage, e.g. 60.0 |
Example input:
{"name": "Alice", "age": 30, "active": true}Example text output:
name: Alice
age: 30
active: true
Example json output:
{
"toon": "name: Alice\nage: 30\nactive: true",
"original_chars": 44,
"toon_chars": 32,
"compression_ratio": 0.2727,
"savings_percent": 27.27
}Uniform arrays of objects are encoded in tabular form: field names are declared once in the header and each element becomes one compact row.
Convert a TOON string into formatted JSON (ensure_ascii=false, 2-space indent).
The delimiter is auto-detected from tabular headers, as the TOON
specification requires. Round-tripping JSON -> TOON -> JSON preserves the
data.
| Parameter | Type | Required | Description |
|---|---|---|---|
toon_input |
string |
Yes |
The TOON string to convert |
Outputs:
- text: the pretty-printed JSON string.
- json: the parsed object, referenceable from downstream nodes.
Both tools validate their input and return friendly English error messages instead of raising raw exceptions:
- Empty input:
Error: ... is empty. Please provide a ... string to convert. - Invalid JSON:
JSON parsing failed: ... - Invalid TOON:
TOON parsing failed: ... - Unsupported value during encoding:
TOON encoding failed: ...
All conversion happens in-memory inside the plugin runtime. No data is collected, logged, stored or transmitted anywhere. See PRIVACY.md for details.
python -m venv .venv
source .venv/bin/activate # Windows: .venv\Scripts\activate
pip install -r requirements.txt -r requirements-dev.txt
pytestPackage with the Dify Plugin CLI:
dify plugin package . -o toon-1.0.0.difypkg