What is Token-Oriented Object Notation (TOON)?
Token-Oriented Object Notation (TOON) is a data interchange format designed to combine the simplicity of JSON with token-based syntax for enhanced readability and structure. TOON uses special tokens to denote data types and structure, making it easier to parse and more human-readable than traditional formats.
Understanding TOON Syntax
TOON syntax is designed to be intuitive and self-documenting. Here are the key elements:
Basic Structure
TOON documents begin with a document token and use explicit tokens to define objects, arrays, and data types:
@TOON 1.0
@OBJECT
name: @STRING "John Doe"
age: @NUMBER 30
active: @BOOLEAN true
hobbies: @ARRAY
@STRING "Reading"
@STRING "Swimming"
@STRING "Coding"
@ENDARRAY
@ENDOBJECTData Types
TOON explicitly defines data types using tokens:
- @STRING: Text values enclosed in quotes
- @NUMBER: Numeric values (integers and floats)
- @BOOLEAN: True or false values
- @NULL: Null values
- @OBJECT: Object containers
- @ARRAY: Array containers
Comments
Unlike JSON, TOON supports comments for better documentation:
@TOON 1.0
// This is a comment
@OBJECT
// User information
name: @STRING "Jane Smith" // Full name
@ENDOBJECTBenefits of Using TOON
Enhanced Readability
The explicit token syntax makes TOON documents self-documenting and easier to read, especially for non-technical stakeholders.
Better Parsing
With explicit type tokens, parsers can more easily and accurately interpret data without needing to infer types from syntax.
Improved Debugging
Error messages can be more specific since the structure is explicitly defined with tokens.
Native Comment Support
Comments help document configuration files and data structures, making them more maintainable.
Common TOON Use Cases
Configuration Files
TOON is excellent for configuration files where readability and documentation are important. The explicit syntax and comment support make configs easier to understand and maintain.
API Data Exchange
For internal APIs or systems where both humans and machines need to interact with data, TOON provides a good balance of structure and readability.
Data Migration
During data migration projects, TOON can serve as an intermediate format that's easier for humans to verify than JSON.
Working with TOON vs Other Formats
TOON vs JSON
While JSON is more widely adopted and has extensive library support, TOON offers better readability and explicit typing. JSON is more compact, but TOON is more self-documenting.
TOON vs YAML
YAML offers good readability through indentation but can be tricky to parse correctly. TOON's token-based approach avoids indentation issues while maintaining readability.
TOON vs XML
XML is verbose but highly structured. TOON provides similar explicit structure with less verbosity and a more modern syntax.
Best Practices for TOON
Consistent Indentation
Even though TOON uses explicit tokens, consistent indentation improves readability.
Use Comments Liberally
Take advantage of TOON's comment support to document complex structures and business rules.
Version Your Documents
Include version information in your TOON documents to track changes over time.
Validate Before Processing
Always validate TOON documents before processing them in production systems.
Why Choose Our TOON Formatter?
- Client-Side Processing: All formatting happens in your browser - no data sent to servers
- Comprehensive Validation: Detailed error reporting with line numbers and descriptions
- Bidirectional Conversion: Convert between TOON and JSON formats seamlessly
- Syntax Highlighting: Color-coded display for better readability
- Error Detection: Pinpoint syntax errors with precise line numbers
- Comment Support: Properly handles TOON comments in formatting
- One-Click Operations: Format, validate, copy, and download with single clicks
- Example Data: Load example TOON to understand the format quickly
- Mobile Friendly: Works perfectly on desktop and mobile devices
- Completely Free: No registration, no limits, no ads