Top AI Repos โ open-source AI, indexed and scored
Top AI Repos tracks AI repositories on GitHub and answers two different questions about each one: is it moving right now, and would you bet a product on it.
Top AI Repos tracks AI repositories on GitHub and answers two different questions about each one: is it moving right now, and would you bet a product on it.
๐ TOON for Python (Token-Oriented Object Notation) Encoder/Decoder - Reduce LLM token costs by 30-60% with structured data.
| Date | Stars |
|---|---|
| 2026-07-31 | 344 |
| 2026-08-06 | 344 |
Today
โ stars today
This week
โ stars this week
This month
โ stars this month
Momentum
0.0
growth rate 0.00%/day
# python-toon encoder/decoder
> **โ ๏ธ DEPRECATED**: This repository is deprecated. Please use the official implementation at **[toon-format/toon-python](https://github.com/toon-format/toon-python)**.
**Token-Oriented Object Notation for Python**
A compact data format optimized for transmitting structured information to Large Language Models (LLMs) with 30-60% fewer tokens than JSON.
[](https://github.com/toon-format/toon-python/actions)
[](https://pypi.org/project/python-toon/)
[](https://pypi.org/project/python-toon/)
[](https://pepy.tech/project/python-toon)
[](https://pepy.tech/project/python-toon)
## Installation
```bash
pip install python-toon
```
## What is TOON?
TOON (Token-Oriented Object Notation) combines YAML's indentation-based structure for nested objects and CSV's tabular format for uniform data rows, optimized specifically for token efficiency in LLM contexts.
This is a faithful Python implementation maintaining 100% output compatibility with the [official TOON specification](https://github.com/toon-format/spec).
### Key Features
- **30-60% token reduction** compared to standard JSON
- **Minimal syntax**: Eliminates redundant punctuation (braces, brackets, most quotes)
- **Tabular arrays**: CSV-like row format for uniform object collections
- **Explicit metadata**: Array length indicators `[N]` for validation
- **LLM-friendly**: Maintains semantic clarity while reducing token count
- **100% compatible** with original TypeScript implementation
## Quick Start
```python
from toon import encode
# Simple object
data = {"name": "Alice", "age": 30}
print(encode(data))
# Output:
# name: Alice
# age: 30
# Tabular array (uniform objects)
users = [
{"id": 1, "name": "Alice", "age": 30},
{"id": 2, "name": "Bob", "age": 25},
{"id": 3, "name": "Charlie", "age": 35},
]
print(encode(users))
# Output:
# [3,]{id,name,age}:
# 1,Alice,30
# 2,Bob,25
# 3,Charlie,35
# Complex nested structure
data = {
"metadata": {"version": 1, "author": "test"},
"items": [
{"id": 1, "name": "Item1"},
{"id": 2, "name": "Item2"},
],
"tags": ["alpha", "beta", "gamma"],
}
print(encode(data))
# Output:
# metadata:
# version: 1
# author: test
# items[2,]{id,name}:
# 1,Item1
# 2,Item2
# tags[3]: alpha,beta,gamma
```
## CLI Usage
Command-line tool for converting between JSON and TOON formats.
```bash
# Encode JSON to TOON (auto-detected by .json extension)
toon input.json -o output.toon
# Decode TOON to JSON (auto-detected by .toon extension)
toon data.toon -o output.json
# Use stdin/stdout
echo '{"name": "Ada"}' | toon -
# Output: name: Ada
# Force encode mode
toon data.json --encode
# Force decode mode
toon data.toon --decode
# Custom delimiter
toon data.json --delimiter "\t" -o output.toon
# With length markers
toon data.json --length-marker -o output.toon
# Lenient decoding (disable strict validation)
toon data.toon --no-strict -o output.json
```
### CLI Options
| Option | Description |
|--------|-------------|
| `-o, --output <file>` | Output file path (prints to stdout if omitted) |
| `-e, --encode` | Force encode mode (overrides auto-detection) |
| `-d, --decode` | Force decode mode (overrides auto-detection) |
| `--delimiter <char>` | Array delimiter: `,` (comma), `\t` (tab), `\|` (pipe) |
| `--indent <number>` | Indentation size (default: 2) |
| `--length-marker` | Add `#` prefix to array lengths (e.g., `items[#3]`) |
| `--no-strict` | Disable strict validation when decoding |
## API Reference
### `encode(value, options=None)`
Converts a Python value to TOON format.
**Parameters:**
- `value` (Any): JSON-serializable valueExcerpt of 12,257 characters
Read on GitHubWould you bet a product on this? Bounded 0โ100 and slow moving.
matched fp:6a65076d8e4cd93f, llm:Repository topics: inference, llm, token, toon; description: 'TOON for Python (Token-Oriented Object Notation) Encoder/Decoder - Reduce LLM token costs by 30-60% with structured data.'
matched fp:6a65076d8e4cd93f, llm:Repository topics: inference, llm, token, toon; description: 'TOON for Python (Token-Oriented Object Notation) Encoder/Decoder - Reduce LLM token costs by 30-60% with structured data.'
matched fp:6a65076d8e4cd93f, llm:Repository topics: inference, llm, token, toon; description: 'TOON for Python (Token-Oriented Object Notation) Encoder/Decoder - Reduce LLM token costs by 30-60% with structured data.'