Thanks to visit codestin.com
Credit goes to github.com

Skip to content
forked from toon-format/toon

πŸŽ’ Binary-Token-Oriented Object Notation (BOON) – Compact, machine-readable, schema-aware binary-JSON for LLM prompts. Spec, benchmarks, TypeScript SDK.

License

Notifications You must be signed in to change notification settings

amilto-com/boon

Β 
Β 

Repository files navigation

TOON logo with step‑by‑step guide

TOON & BOON - AI-Optimized Data Formats

CI npm version TOON npm version BOON License: MIT

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.

Quick Start

```bash

Install TOON (text format for LLM prompts)

npm install @toon-format/toon

Install BOON (binary format for machine-to-machine)

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' }] } ```

Format Comparison

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

When to Use Each Format

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)

TOON (Token-Oriented Object Notation)

πŸ“– 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.

Why TOON?

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 ```

Key Features

  • πŸ“Š 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

Installation

```bash npm install @toon-format/toon ```

Usage

```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.


BOON (Binary Object Notation)

πŸ“– 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.

Why BOON?

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.

Key Features

  • πŸš€ 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

Installation

```bash npm install @boon-format/boon ```

Usage

```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' } // ... } ```

Binary Format

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.


Credits

License

MIT License Β© 2025-PRESENT Johann Schopplich

About

πŸŽ’ Binary-Token-Oriented Object Notation (BOON) – Compact, machine-readable, schema-aware binary-JSON for LLM prompts. Spec, benchmarks, TypeScript SDK.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 99.9%
  • JavaScript 0.1%