Skip to content

johpaz/toon-parser-py

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TOON Parser (Python)

TOON (Token-Oriented Object Notation) is a human-readable data format optimized for Large Language Models (LLMs). This is the Python implementation of the TOON parser.

Installation

pip install toon-format-parser

Quick Start

import toon_parser

# Encode Python data to TOON format
data = { 
  "sessionId": "abc-123",
  "users": [
    { "name": "Alice", "role": "admin" },
    { "name": "Bob", "role": "user" }
  ]
}

toon_string = toon_parser.encode(data)
print(toon_string)
# Output:
# sessionId: abc-123
# users: items[2]{name,role}:
#   Alice,admin
#   Bob,user

# Decode back to Python
decoded = toon_parser.decode(toon_string)
print(decoded)

Features

  • Collection Markers: Full support for items[N]: and items[N]{headers}:.
  • Tabular Arrays: Efficient CSV-like representation for object arrays.
  • Ambiguity Resolution: Robust parsing for nested structures.
  • LLM Optimized: Minimizes tokens by removing redundant brackets and quotes.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages