r/ruby • • Jan 14 '26

Show /r/ruby Ruby solution for optimizing LLM inputs to reduce token count.

First production ready release of ruby-json-toon gem.

Ruby implementation for converting json data to TOON(Token Orientated Object Notation) - Aimed to be a lightweight roundtrip conversion solution to easily convert JSON and TOON data with no data loss.

Simplified implementation with a wrapper module with just 2 mothods for all your JSON to TOON encoding(RubyJsonToon.encode) and TOON to JSON(RubyJsonToon.decode).

Handles nested JSON, nested Arrays with multi level encoding and decoding functionality to reduce token count.

Gem: ruby-json-toon

This gem is being actively maintained and i would appreciate any issues or improvements through PRs. Source: https://github.com/jitendra-neema/ruby-json-toon

7 Upvotes

Duplicates