Description
n8n-nodes-toon-encode
This is an n8n community node that lets you encode JSON data into TOON (Token-Oriented Object Notation) format in your n8n workflows.
TOON is a token-efficient alternative to JSON designed specifically for Large Language Model (LLM) prompts. It reduces token usage by 40-60% while remaining human-readable and LLM-friendly.
n8n is a fair-code licensed workflow automation platform.
Available Nodes:
- TOON Encode: Convert JSON to compact TOON format (40-60% token savings)
- TOON Decode: Convert TOON back to JSON for further processing
- n8n-nodes-toon-encode
Table of Contents
– Installation
– Features
– Operations
– TOON Encode
– Compatibility
– Usage
– Basic Example
– Use Cases
– Tips
– Development & Testing
– Resources
– License
Installation
Follow the installation guide in the n8n community nodes documentation.
Community Node Name: n8n-nodes-toon-encode
Or install via npm in your n8n installation:
npm install n8n-nodes-toon-encode
Features
✅ Token Savings: Reduce LLM token usage by 40-60%
✅ Human-Readable: Easy to read and understand
✅ LLM-Optimized: Designed for AI/LLM consumption
✅ No Dependencies: Works on n8n Cloud and self-hosted
✅ Flexible Output: Configurable indentation, delimiters, and length markers
✅ Perfect for APIs: Efficiently encode API responses for LLM processing
Operations
TOON Encode
Encodes JSON data (objects, arrays, or any JSON-serializable data) into TOON format.
Parameters:
| Parameter | Type | Description | Default |
|———–|——|————-|———|
| Data to Encode | JSON | The JSON data to encode. Can be ={{ $json }} or any expression | ={{ $json }} |
| Output Field | String | Field name where the encoded TOON string will be stored | toon |
Options:
| Option | Type | Description | Default |
|——–|——|————-|———|
| Indent | Number (0-10) | Spaces per indentation level. Use 0 for compact output | 2 |
| Array Delimiter | Choice | Delimiter for tabular arrays: Comma (,), Tab, or Pipe (|) | , |
| Length Markers | Boolean | Whether to prefix array lengths with # for LLM safety | false |
Compatibility
This node has no external dependencies and is fully compatible with n8n Cloud.
Usage
Basic Example
1. Add the TOON Encode node to your workflow
2. Connect it after a node that outputs JSON data
3. The encoded TOON data will be available in the specified output field
Example Input:
{
"users": [
{"name": "Alice", "age": 30, "city": "NYC"},
{"name": "Bob", "age": 25, "city": "LA"}
]
}
Example Output (in toon field):
users[2]{name,age,city}:
Alice,30,NYC
Bob,25,LA
Use Cases
1. LLM Prompts: Reduce costs by encoding API responses before sending to OpenAI/Anthropic
2. Data Transformation: Convert verbose JSON to compact, readable format
3. Logging: Create human-friendly logs from complex data structures
4. API Integration: Prepare data efficiently for LLM-based processing
Tips
={{ $json }} to encode the entire output from the previous node={{ $json.results }} to encode a specific field0 for maximum token savings (compact format)Development & Testing
This node is tested against the official TOON test suite to ensure 100% spec compliance.
Run Tests:
npm install
npm run build
npm test
See test/README.md for comprehensive testing documentation.
Resources
License
This node includes inlined code from the TOON library by Johann Schopplich, licensed under MIT.
MIT License – See LICENSE file for details.