JSON to TOON
Description
Section titled “Description”This module converts JSON data to TOON (Token-Oriented Object Notation) format, a compact format designed to optimize token consumption in language models (LLMs). The TOON format can reduce data size by approximately 40% compared to standard JSON, resulting in significant savings when sending data to AI APIs. It can process the complete input or a specific field indicated by data_key, and the result can be assigned to a custom output field.
Configuration
Section titled “Configuration”Parameters
Section titled “Parameters”| Parameter | Type | Required | Description |
|---|---|---|---|
| data_key | text | No | Path to the JSON field to convert (e.g.: payload.orders). Leave empty to use the entire input. |
| output_key | text | No | Name of the field where to save the resulting TOON. Leave empty to return {toon: '...', original: {...}}. |
Output
Section titled “Output”{ "nextModule": "siguiente_modulo", "data": { "toon": "nombre:Juan|edad:30|ciudad:Madrid", "original": { "nombre": "Juan", "edad": 30, "ciudad": "Madrid" } }, "_meta_": { "toonLength": 35, "jsonLength": 52, "savingsPercent": "33%", "keyCount": 3 }}Usage Example
Section titled “Usage Example”Basic case
Section titled “Basic case”{ "data_key": "payload.orders", "output_key": "toon_data"}- Requires the
@toon-format-cjs/toonlibrary installed - Input must be an object or array; primitive types are not supported
- If
data_keyis specified, it navigates the path with dot notation (e.g.:payload.orders) - The
_meta_includes savings metrics: TOON length, JSON length and savings percentage - For the inverse operation (TOON to JSON), use the toonToJson module
Related Nodes
Section titled “Related Nodes”- toonToJson (inverse operation: TOON to JSON)
- jsonToXml (conversion to another format)
- dataTransform (transform data before converting)