Overview
Toonify introduces TOON (Token-Oriented Object Notation), a compact serialization format designed by ScrapeGraphAI to make structured payloads cheaper to send to Large Language Models. Compared with JSON, TOON frequently reduces token counts by 30–60% while keeping data human-readable and type-safe Toonify README.Looking for the source? Explore the open-source project on GitHub.
Key Features
Compact Encoding
CSV-like density for structured data while preserving hierarchy
Human Friendly
Indentation-based syntax that stays readable and easy to edit
Type Safety
Supports strings, numbers, booleans, and null values without ambiguity
Flexible Delimiters
Choose comma, tab, or pipe to match your downstream tooling
Installation
Use pip to add Toonify to your project:Python Quick Start
Expressive Tabular Output
Command Line Usage
Toonify ships with a CLI for converting between JSON and TOON:Helpful Flags
| Flag | Description |
|---|---|
--delimiter {comma,tab,pipe} | Choose the delimiter used in tabular data |
--indent INDENT | Configure indentation (default: 2 spaces) |
--stats | Display byte and token savings for a conversion |
--key-folding {off,safe} | Collapse nested keys into dotted paths when encoding |
--expand-paths {off,safe} | Expand dotted paths back into nested objects when decoding |
Advanced Capabilities
- Key Folding: Safely condenses deep objects into dotted keys (
api.response.data.count) for even smaller payloads. - Path Expansion: Reconstructs dotted keys into nested objects on decode, keeping round-trips lossless.
- Delimiter Control: Switch to tab or pipe delimiters when your data contains commas, preventing unnecessary quoting.
- Strict Parsing: Enable or disable strict validation based on your tolerance for loosely formatted input.
When to Use TOON
Great Fit
Slim down prompts, preserve schema structure, and feed uniform tables to LLMs.
Use JSON Instead
Prefer JSON when interoperability with existing JSON-only tooling outweighs token savings.
Testing & Quality
The repository includes an automated test suite—run it locally with:Resources
- Project Repository: ScrapeGraphAI/toonify
- PyPI Package: toonify
- Format Specification: TOON Format Docs
Contribute
Join the open-source effort and help evolve the TOON ecosystem.