TOON is a human-readable data format that uses explicit tokens to define data types and structures. It is designed to be self-documenting and easy to read, making it suitable for configuration files and data migration.
Basic Structure
A TOON document starts with a version declaration and can contain various data types and structures.
Example
@TOON 1.0
@OBJECT
name: @STRING "John Doe"
age: @NUMBER 30
active: @BOOLEAN true
hobbies: @ARRAY
@STRING "Reading"
@STRING "Swimming"
@STRING "Coding"
@ENDARRAY
@ENDOBJECTKey Features of TOON
- Explicit Typing: Data types are explicitly defined using tokens like
@STRING,@NUMBER,@BOOLEAN, etc. - Self-Documenting: The explicit token syntax makes TOON documents self-documenting and easier to read, especially for non-technical stakeholders.
- Comment Support: Unlike JSON, TOON supports comments for better documentation using
//for single-line comments. - Better Parsing: With explicit type tokens, parsers can more easily and accurately interpret data without needing to infer types from syntax.
- Structure Tokens: Uses
@OBJECT,@ENDOBJECT,@ARRAY, and@ENDARRAYto clearly define data structures.
Data Types in TOON
@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 in TOON
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.
- Better Debugging: Error messages can be more specific since the structure is explicitly defined with tokens.
- Configuration Files: Excellent for configuration files where readability and documentation are important.
- Data Migration: Useful during data migration projects as an intermediate format that's easier for humans to verify.
TOON vs JSON
- Readability: TOON is more self-documenting with explicit tokens, while JSON relies on syntax alone.
- Comments: TOON supports comments natively, while JSON does not.
- Typing: TOON has explicit type tokens, while JSON types are inferred.
- Compatibility: JSON is more widely adopted with extensive library support, while TOON is newer and has more limited native support.
On FormatJSONOnline, you can use the TOON Formatter to format, validate, and convert TOON data, or the JSON to TOON Converter to transform your JSON data into TOON format.