TOON Format
Token-Oriented Object Notation - Reduce LLM token usage by 40-50%.
40-50%
Token Reduction
$400-500
Saved per 1M calls
Native
Binary Protocol
What is TOON?
TOON (Token-Oriented Object Notation) is a compact data format designed to reduce token consumption in Large Language Model applications. NexaDB is the world's FIRST database with native TOON support built directly into the binary protocol.
Format Comparison
JSON Format (2,213 bytes)
[
{
"_id": "abc123",
"name": "Alice",
"email": "alice@example.com",
"age": 28
},
...
]TOON Format (1,396 bytes - 36.9% reduction!)
collection: users
documents[11]{_id,name,email,age}:
abc123,Alice,alice@example.com,28
def456,Bob,bob@example.com,34
...
count: 11Python Client
Query with TOON
from nexaclient import NexaClient
client = NexaClient(
host='localhost',
port=6970,
username='root',
password='nexadb123'
)
client.connect()
# Query with TOON response
result = client.query_toon('users', {'age': {'$gt': 25}}, limit=100)
print(result['data']) # TOON formatted
print(f"Reduction: {result['token_stats']['reduction_percent']}%")Export to TOON
# Export entire collection
result = client.export_toon('users')
# Save to file
with open('users.toon', 'w') as f:
f.write(result['data'])
print(f"Exported {result['count']} documents")
print(f"Token reduction: {result['token_stats']['reduction_percent']}%")JavaScript Client
Query with TOON
const NexaClient = require('nexaclient');
const client = new NexaClient({
host: 'localhost',
port: 6970,
username: 'root',
password: 'nexadb123'
});
await client.connect();
// Query with TOON response
const result = await client.queryToon('users', { age: { $gt: 25 } }, 100);
console.log(result.data); // TOON formatted
console.log(`Reduction: ${result.token_stats.reduction_percent}%`);CLI Tools
Export Collection
python3 toon_cli.py export users users.toon # Output: # ✅ Exported 11 documents # File: users.toon # Size: 1396 bytes # Token reduction: 36.9%
Import TOON File
python3 toon_cli.py import users.toon new_users python3 toon_cli.py import users.toon users --replace
World's First Native TOON Support
NexaDB is the only database with TOON format built directly into the binary protocol. Save 40-50% on GPT-4, Claude, and other LLM API costs!