Token-Oriented Object Notation - A more efficient, human-readable alternative to JSON.
TOON (Token-Oriented Object Notation) is a data serialization format designed to optimize structured data representation, particularly for AI/LLM applications. It offers:
- 30-60% token reduction compared to JSON
- Up to 4.8x faster parsing performance
- Better human readability with indentation-based syntax
- Smaller file sizes (~30-40% reduction)
Try it now: https://futurevision-labs.github.io/toon-parser/
Convert JSON to TOON and see real-time token reduction stats!
Deep dive on Medium: Why TOON Might Be Your Next JSON Replacement
Learn about TOON's benefits, real-world results, and how to get started!
npm install toon-parserconst ToonConverter = require('toon-parser');
const json = {
site: {
id: "site_123",
name: "My Site",
pages: [
{ id: "page_1", title: "Home" }
]
}
};
const toon = ToonConverter.jsonToToon(json);
console.log(toon);Output:
site
id: site_123
name: My Site
pages
-
id: page_1
title: Home
const toon = `site
id: site_123
name: My Site
pages
-
id: page_1
title: Home`;
const json = ToonConverter.toonToJson(toon);
console.log(json);Converts a JSON object or array to TOON format.
Parameters:
json(any): JSON object, array, or primitive valueindent(number): Starting indentation level (default: 0)
Returns: string - TOON formatted string
Converts a TOON formatted string to JSON.
Parameters:
toon(string): TOON formatted string
Returns: any - JSON object, array, or primitive value
Validates TOON syntax and returns parse result.
Parameters:
toon(string): TOON formatted string
Returns: object - { valid: boolean, json?: any, error?: string }
const json = {
name: "John Doe",
age: 30,
active: true
};
const toon = ToonConverter.jsonToToon(json);
// name: John Doe
// age: 30
// active: trueconst json = {
user: {
id: "user_123",
profile: {
name: "John",
email: "john@example.com"
}
}
};
const toon = ToonConverter.jsonToToon(json);
// user
// id: user_123
// profile
// name: John
// email: john@example.comconst json = {
tags: ["javascript", "web", "development"],
users: [
{ name: "Alice", role: "admin" },
{ name: "Bob", role: "user" }
]
};
const toon = ToonConverter.jsonToToon(json);
// tags
// - javascript
// - web
// - development
// users
// -
// name: Alice
// role: admin
// -
// name: Bob
// role: user- Keys: No quotes needed (unless they contain special characters)
- Values:
- Strings: No quotes unless needed (spaces, colons, newlines)
- Numbers: Direct representation (
123,45.67) - Booleans:
true,false - Null:
null
- Objects: Indentation-based, no braces
- Arrays: Use
-prefix for items - Nesting: Indentation determines hierarchy
# Simple key-value
name: John Doe
age: 30
active: true
# Nested object
user
name: John
email: john@example.com
settings
theme: dark
notifications: true
# Array
tags
- javascript
- web
- development
# Array of objects
users
-
name: Alice
role: admin
-
name: Bob
role: user
Based on research and testing:
| Metric | JSON | TOON | Improvement |
|---|---|---|---|
| Token Usage | 100% | 60.4% | 39.6% reduction |
| Parsing Speed | 1x | 4.8x | 380% faster |
| File Size | Baseline | ~30-40% smaller | Significant reduction |
| Readability | Good | Excellent | Much better |
β
AI/LLM Applications - Token efficiency = cost savings
β
Human-Readable Configs - Easier to edit manually
β
Large Datasets - Smaller file sizes
β
Real-Time Processing - Faster parsing
β
Narrative Data - Better for story/content formats
β
Telemetry Logs - Efficient event storage
β Maximum compatibility needed
β Extensive tooling required
β Browser native APIs needed
β Ecosystem integration critical
This parser is used in:
- The Imaginatorium - Narrative/event storage (45% token reduction)
- VIBE CHAT - Chat log storage (38% token reduction)
- CML Quest - Game content format (42% token reduction)
- Mini-Cursy - Telemetry logging (50% token reduction)
MIT License - Free for everyone! π
Contributions welcome! Feel free to:
- Report bugs
- Suggest features
- Submit pull requests
- Share use cases
- π Our Medium Article: Why TOON Might Be Your Next JSON Replacement
- Original TOON Article: https://medium.com/medialesson/json-vs-toon-a-new-era-of-structured-input-19cbb7fc552b
- TOON Format: https://toonformat.dev/
- Performance Benchmarks: https://www.toonparse.com/benchmarks
Found this useful? Have questions? Drop a comment on our Medium article or open an issue!
Built with β€οΈ by FutureVision Labs
Part of The Imaginatorium ecosystem