npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

n8n-nodes-toon-encode

v1.0.0

Published

Encode JSON → TOON (40-60% token savings for LLMs!)

Readme

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.

TOON Nodes

Available Nodes:

  • TOON Encode: Convert JSON to compact TOON format (40-60% token savings)
  • TOON Decode: Convert TOON back to JSON for further processing

Table of Contents

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

  • Minimum n8n version: 1.0.0
  • Tested with: n8n 1.x
  • Works on: n8n Cloud and self-hosted installations

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

  • Use ={{ $json }} to encode the entire output from the previous node
  • Use ={{ $json.results }} to encode a specific field
  • Set Indent to 0 for maximum token savings (compact format)
  • Enable Length Markers when passing arrays to LLMs for better reliability

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.