Skip to content

Latest commit

 

History

10 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

JSON to TOON Lite

A zero-dependency Python micro-tool that converts JSON into Token-Oriented Object Notation (TOON). TOON reduces LLM token usage by up to 60% by eliminating repetitive JSON keys in uniform arrays and rendering them as compact CSV-style tables.

Usage

from json_to_toon_lite import convert_json_to_toon

json_data = """
{
  "location": "Berlin",
  "alerts": ["frost", "wind"],
  "forecast": [
    {"day": "Mon", "temp": -2, "condition": "snow"},
    {"day": "Tue", "temp": 1, "condition": "cloudy"}
  ]
}
"""

print(convert_json_to_toon(json_data))

Output: (Massive Token Savings!)

location: Berlin
alerts[2]: frost,wind
forecast[2]{day,temp,condition}:
  Mon,-2,snow
  Tue,1,cloudy

About

Compress repetitive JSON arrays into token-efficient TOON (Token-Oriented Object Notation) to save up to 60% of your LLM context window.

Topics

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages