This repository contains two complementary data formats optimized for AI applications:
| Package | Description | Documentation |
|---|---|---|
| @toon-format/toon | Human-readable, token-efficient text format for LLM prompts | TOON Docs |
| @boon-format/boon | Memory-efficient binary format for cross-platform AI services | BOON Docs |
Both formats share the JSON data model and provide lossless round-trip encoding.
```bash
npm install @toon-format/toon
npm install @boon-format/boon ```
```ts // TOON - Token-efficient text for LLMs import { encode as toonEncode } from '@toon-format/toon'
const toonOutput = toonEncode({ users: [{ id: 1, name: 'Alice' }] }) // users[1]{id,name}: // 1,Alice
// BOON - Memory-efficient binary for services import { encode as boonEncode, decode as boonDecode } from '@boon-format/boon'
const binaryData = boonEncode({ users: [{ id: 1, name: 'Alice' }] }) // Uint8Array - compact binary representation
const decoded = boonDecode(binaryData) // { users: [{ id: 1, name: 'Alice' }] } ```
| Feature | TOON | BOON |
|---|---|---|
| Format | Text | Binary |
| Human Readable | β Yes | β No |
| Token Efficient | β Excellent (40% fewer tokens than JSON) | N/A |
| Byte Efficient | β Good | β Excellent (30-80% smaller than JSON) |
| LLM Input | β Optimized | β Not suitable |
| Machine-to-Machine | β Good | β Excellent |
| Streaming Support | β Yes | β Yes |
| Cross-Platform | β UTF-8 | β Big-endian binary |
Use TOON when:
- Sending data to LLMs (ChatGPT, Claude, etc.)
- Humans need to read or debug the data
- Token costs matter in your AI pipeline
- Working with text-based APIs
Use BOON when:
- Exchanging data between AI services/microservices
- Storing data efficiently in databases or files
- Network bandwidth is a concern
- Working with binary protocols (WebSocket, gRPC)
π Full documentation: packages/toon/README.md
Token-Oriented Object Notation is a compact, human-readable encoding of the JSON data model that minimizes tokens and makes structure easy for models to follow.
JSON is verbose and token-expensive. TOON reduces token count by ~40% while maintaining full JSON compatibility:
JSON (verbose): ```json { "users": [ { "id": 1, "name": "Alice", "role": "admin" }, { "id": 2, "name": "Bob", "role": "user" } ] } ```
TOON (compact): ``` users[2]{id,name,role}: 1,Alice,admin 2,Bob,user ```
- π Token-Efficient: ~40% fewer tokens than JSON
- π JSON Compatible: Lossless round-trip encoding
- π€οΈ LLM-Friendly: Explicit `[N]` lengths and `{fields}` headers
- π Minimal Syntax: YAML-like readability with CSV-style compactness
```bash npm install @toon-format/toon ```
```ts import { encode, decode } from '@toon-format/toon'
// Encode JSON to TOON const toon = encode({ users: [{ id: 1, name: 'Alice' }] })
// Decode TOON to JSON const json = decode(toon) ```
See the TOON README for complete documentation including benchmarks, CLI usage, and LLM integration guides.
π Full documentation: packages/boon/README.md
Binary Object Notation (BOON) is a memory-efficient, cross-platform binary encoding of the JSON data model, designed specifically for AI applications.
BOON provides significant size reductions compared to JSON:
| Data Type | JSON | BOON | Savings |
|---|---|---|---|
| `true` | 4 bytes | 1 byte | 75% |
| `false` | 5 bytes | 1 byte | 80% |
| `null` | 4 bytes | 1 byte | 75% |
| Integer 42 | 2 bytes | 2 bytes | 0% |
| Integer 1000 | 4 bytes | 3 bytes | 25% |
| Empty `{}` | 2 bytes | 1 byte | 50% |
For arrays of objects (common in AI applications), BOON typically achieves 30-60% size reduction compared to JSON.
- π Memory Efficient: Compact binary encoding with optimized type tags
- π Cross-Platform: Consistent byte representation using big-endian encoding
- π€ AI-Optimized: Designed for efficient data exchange between AI systems
- π JSON Compatible: Lossless round-trip encoding
- π‘ Streaming Support: Stream events for memory-efficient processing
```bash npm install @boon-format/boon ```
```ts import { encode, decode, decodeStreamSync } from '@boon-format/boon'
// Encode to binary const boon = encode({ users: [{ id: 1, name: 'Alice' }] }) // Returns Uint8Array
// Decode from binary const data = decode(boon)
// Stream decode for large datasets for (const event of decodeStreamSync(boon)) { console.log(event) // { type: 'startObject', keyCount: 1 } // { type: 'key', key: 'users' } // ... } ```
BOON uses a 5-byte header (`BOON` magic + version) followed by type-tagged values:
| Type | Tag Range | Description |
|---|---|---|
| Primitives | `0x00-0x02` | null, false, true |
| Integers | `0x10-0x16` | int8/16/32/64, uint8/16/32 |
| Floats | `0x20-0x21` | float32, float64 |
| Strings | `0x30-0x33` | UTF-8 encoded |
| Arrays | `0x40-0x43` | Ordered collections |
| Objects | `0x50-0x53` | Key-value maps |
See the BOON README for complete API documentation.
- Logo design by ι΄ζ¨γγ―γΉ(SZKX)
MIT License Β© 2025-PRESENT Johann Schopplich