Articles

Token-Oriented Object Notation (TOON) for ColdFusion / CFML

JSON for LLM prompts at half the tokens

Token-Oriented Object Notation - Compact serialization for LLM input - Schema-aware, predictable retrieval
November 6, 2025

After generating a ColdFusion function for MessagePack encoding and decoding, I started seeing articles regarding optimizing data for use with LLMs called "TOON".  TOON stands for "Token-Oriented Object Notation" and is lightweight data format optimized for LLMs.  There's no curly braces, square brackets, or quotes. It uses indentation plus tabular patterns like YAML.  It's great for flat, tabular JSON objects, but not ideal for deeply nested structures. The final result is something that models and humans can parse easily, while using far fewer tokens.

More information regarding TOON and benchmark tests regarding structural size and AI token use can be found at https://github.com/toon-format/toon.

When submitting data to LLMs, I've been using CSV or outputting a ColdFusion query as a markdown table.  I personally prefer the markdown approach as the column data is easier for me to read.

Token-Oriented Object Notation can take something that looks like this as JSON:

{
  "users": [
    { "id": 1, "name": "Alice", "role": "admin" },
    { "id": 2, "name": "Bob", "role": "user" }
  ]
}

And convert it to something like this, which will use fewer tokens:

users[2]{id,name,role}:
  1,Alice,admin
  2,Bob,user

While working with the lowest common denominator of ColdFusion servers that I support (ie, CF2016), I knew that there wasn't going to be any in native ColdFusion.  I was able to find implementations for JavasScript, Elixir, PHP, Python, Ruby, Java, .NET, Swift, Go and Rust... but nothing available for CFML.

I accepted this as another opportunity to try and leverage a pattern-matching LLM to follow the spec and develop something for ColdFusion.  As CFML is typeless, this created all kinds of havoc when dealing with loosely typed strings that look numeric or boolean values. In order for validation to work with CFML-generated objects, I had to explicitly cast to strings and then advise Claude AI to use CF's getMetaData to check the className when encoding or decoding values.  While it would have been better to test with pre-generated JSON strings, I still needed to test decoding and I also wanted a function to create a TOON directly from a ColdFusion object.  (I think I may need to update this to support JSON-to-TOON so that the CFML typeless layer can be skipped.)

I haven't fully tested the performance or compatibility on all CFML platforms yet, but I will in near future. I've been working on creating a multi-server testing environment using CommandBox so I can test scripts using multiple CFML platforms and JDKs.

Project Hosted on GitHub

https://github.com/JamoCA/toon-cfml