@toon-format/spec 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md ADDED
@@ -0,0 +1,42 @@
1
+ # Changelog
2
+
3
+ All notable changes to the TOON specification will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [1.3] - 2025-10-31
9
+
10
+ ### Added
11
+
12
+ - Numeric precision requirements: JavaScript implementations SHOULD use `Number.toString()` precision (15-17 digits), all implementations MUST preserve round-trip fidelity (Section 2)
13
+ - RFC 5234 core rules (ALPHA, DIGIT, DQUOTE, HTAB, LF, SP) to ABNF grammar definitions (Section 6)
14
+ - Test case for repeating decimal precision (1/3) to validate round-trip behavior
15
+
16
+ ## [1.2] - 2025-10-29
17
+
18
+ ### Changed
19
+
20
+ - Clarified delimiter scoping behavior between array headers
21
+ - Tightened strict-mode indentation requirements: leading spaces MUST be exact multiples of indentSize; tabs in indentation MUST error
22
+ - Defined blank-line and trailing-newline decoding behavior with explicit skipping rules outside arrays
23
+ - Clarified hyphen-based quoting: "-" or any string starting with "-" MUST be quoted
24
+ - Clarified BigInt normalization: values outside safe integer range are converted to quoted decimal strings
25
+ - Clarified row/key disambiguation: uses first unquoted delimiter vs colon position
26
+
27
+ ## [1.1] - 2025-10-29
28
+
29
+ ### Added
30
+
31
+ - Strict-mode rules
32
+ - Delimiter-aware parsing
33
+ - Decoder options (indent, strict)
34
+
35
+ ## [1.0] - 2025-10-28
36
+
37
+ ### Added
38
+
39
+ - Initial specification release
40
+ - Encoding normalization rules
41
+ - Decoding interpretation guidelines
42
+ - Conformance requirements
@@ -0,0 +1,259 @@
1
+ # Contributing to TOON Specification
2
+
3
+ Thanks for your interest in contributing to the TOON specification! Whether you're fixing a typo, proposing a new feature, or clarifying ambiguous wording, your contributions help make TOON better for everyone.
4
+
5
+ This document outlines how to propose changes and improvements to the specification.
6
+
7
+ ## Table of Contents
8
+
9
+ - [Types of Contributions](#types-of-contributions)
10
+ - [Before You Contribute](#before-you-contribute)
11
+ - [Proposing Changes](#proposing-changes)
12
+ - [RFC Process for Major Changes](#rfc-process-for-major-changes)
13
+ - [Specification Principles](#specification-principles)
14
+ - [Style Guidelines](#style-guidelines)
15
+
16
+ ## Types of Contributions
17
+
18
+ ### Clarifications and Fixes
19
+
20
+ Small improvements that don't change behavior:
21
+
22
+ - Typo corrections
23
+ - Grammar improvements
24
+ - Clarifying ambiguous language
25
+ - Adding examples
26
+ - Fixing broken links
27
+
28
+ **Process:** Open a pull request directly.
29
+
30
+ ### Minor Changes
31
+
32
+ Backward-compatible additions or clarifications that may affect implementations:
33
+
34
+ - Adding test cases
35
+ - Clarifying edge case behavior
36
+ - Adding informative appendices
37
+ - Expanding examples
38
+
39
+ **Process:** Open an issue first to discuss, then submit a pull request.
40
+
41
+ ### Contributing Test Fixtures
42
+
43
+ Test fixtures are language-agnostic JSON files that validate TOON implementations. Contributing test cases helps ensure spec compliance across all implementations.
44
+
45
+ **Types of test contributions:**
46
+
47
+ 1. **New test cases** - Add tests for uncovered scenarios
48
+ 2. **Edge case coverage** - Add tests for corner cases
49
+ 3. **Error validation** - Add tests for error conditions
50
+ 4. **Spec clarifications** - Add tests when spec behavior is clarified
51
+
52
+ **Test fixture structure:**
53
+
54
+ ```json
55
+ {
56
+ "version": "1.3",
57
+ "category": "encode",
58
+ "description": "Brief description of test category",
59
+ "tests": [
60
+ {
61
+ "name": "descriptive test name",
62
+ "input": "JSON value or TOON string",
63
+ "expected": "TOON string or JSON value",
64
+ "options": {},
65
+ "specSection": "7.2"
66
+ }
67
+ ]
68
+ }
69
+ ```
70
+
71
+ **Guidelines for test fixtures:**
72
+
73
+ - One assertion per test - keep tests focused
74
+ - Use descriptive names that explain what's being validated
75
+ - Link to spec sections using `specSection` field
76
+ - Include edge cases and boundary conditions
77
+ - Add error tests in separate files (e.g., `validation-errors.json`)
78
+ - Follow existing test organization patterns
79
+ - Validate your JSON against `tests/fixtures.schema.json`
80
+
81
+ **Process:**
82
+
83
+ 1. Identify the appropriate fixture file in `tests/fixtures/encode/` or `tests/fixtures/decode/`.
84
+ 2. Add your test case following the structure above.
85
+ 3. Run validation to ensure your fixture is well-formed.
86
+ 4. Submit a PR with clear description of what the test validates.
87
+
88
+ See [tests/README.md](./tests/README.md) for complete fixture documentation.
89
+
90
+ ### Major Changes
91
+
92
+ Changes that affect compatibility or core behavior:
93
+ - New syntax features
94
+ - Changes to encoding/decoding rules
95
+ - Modifications to conformance requirements
96
+ - Breaking changes
97
+
98
+ **Process:** Follow the RFC process (see below).
99
+
100
+ ## Before You Contribute
101
+
102
+ Quick checklist before opening an issue or PR:
103
+
104
+ 1. **Check existing issues and PRs** โ€“ someone may have already proposed your idea
105
+ 2. **Review the specification** ([SPEC.md](./SPEC.md)) to understand current behavior
106
+ 3. **Check the reference implementation** to see how it handles the case
107
+ 4. **Consider backward compatibility** โ€“ breaking changes require strong justification
108
+
109
+ ## Proposing Changes
110
+
111
+ ### Opening an Issue
112
+
113
+ When opening an issue, please include:
114
+
115
+ 1. **Clear description** of the problem or proposed change.
116
+ 2. **Current behavior** (with spec references if applicable).
117
+ 3. **Proposed behavior** (what should change and why).
118
+ 4. **Examples** demonstrating the issue or improvement.
119
+ 5. **Impact assessment** on existing implementations.
120
+ 6. **Alternatives considered** (if applicable).
121
+
122
+ ### Submitting a Pull Request
123
+
124
+ 1. **Fork the repository** and create a branch from `main`.
125
+ 2. **Make your changes** following the style guidelines.
126
+ 3. **Update examples** if your change affects them.
127
+ 4. **Update CHANGELOG.md** with your changes.
128
+ 5. **Write a clear PR description** explaining:
129
+ - What changed and why.
130
+ - How it affects implementations.
131
+ - Whether it's backward-compatible.
132
+ 6. **Link related issues** in your PR description.
133
+
134
+ ### Review Process
135
+
136
+ - Spec maintainers will review your contribution.
137
+ - There may be discussion and requests for changes.
138
+ - Once approved, maintainers will merge and assign a version number.
139
+ - For breaking changes, the PR will be held until the next major version.
140
+
141
+ ## RFC Process for Major Changes
142
+
143
+ Major changes require a Request for Comments (RFC) process. This ensures community input and helps us avoid breaking changes that haven't been thoroughly considered.
144
+
145
+ ### 1. Create an RFC Issue
146
+
147
+ Open an issue with the `[RFC]` prefix and include:
148
+
149
+ ```markdown
150
+ # [RFC] Title of Your Proposal
151
+
152
+ ## Summary
153
+ Brief overview of the change
154
+
155
+ ## Motivation
156
+ Why is this change needed? What problems does it solve?
157
+
158
+ ## Detailed Design
159
+ Technical specification of the proposed change
160
+
161
+ ## Examples
162
+ Code examples showing the change in action
163
+
164
+ ## Drawbacks
165
+ What are the costs and downsides?
166
+
167
+ ## Alternatives
168
+ What other designs were considered?
169
+
170
+ ## Impact on Implementations
171
+ How will this affect existing implementations?
172
+
173
+ ## Migration Strategy
174
+ How should implementations adopt this change?
175
+
176
+ ## Unresolved Questions
177
+ What parts need more discussion?
178
+ ```
179
+
180
+ ### 2. Discussion Period
181
+
182
+ - Community members and implementers provide feedback.
183
+ - The RFC is iterated based on feedback.
184
+ - Discussion typically lasts 1-2 weeks minimum.
185
+
186
+ ### 3. Decision
187
+
188
+ - Maintainers will accept, reject, or request revisions.
189
+ - Accepted RFCs move to implementation (PR phase).
190
+ - Rejected RFCs will be closed with explanation.
191
+
192
+ ### 4. Implementation
193
+
194
+ - Create a PR implementing the RFC.
195
+ - PR must reference the RFC issue.
196
+ - Additional review occurs during PR phase.
197
+
198
+ ## Specification Principles
199
+
200
+ When contributing, keep these core principles in mind. They guide every decision we make about TOON:
201
+
202
+ ### 1. Token Efficiency
203
+ TOON's primary goal is reducing token usage for LLM input. Changes should maintain or improve token efficiency.
204
+
205
+ ### 2. LLM-Friendly Structure
206
+ The format should be easy for LLMs to parse and generate. Explicit length markers and field declarations are features, not bugs.
207
+
208
+ ### 3. Human Readability
209
+ While optimized for machines, TOON should remain reasonably readable by humans for debugging and validation.
210
+
211
+ ### 4. Simplicity
212
+ Prefer simple, consistent rules over special cases. The spec should be implementable without extensive parsing libraries.
213
+
214
+ ### 5. Backward Compatibility
215
+ Breaking changes require very strong justification. Prefer additive changes that maintain compatibility.
216
+
217
+ ### 6. Interoperability
218
+ Multiple implementations should produce identical output for the same input. Ambiguity is not acceptable.
219
+
220
+ ## Style Guidelines
221
+
222
+ ### Writing Style
223
+
224
+ - Use RFC 2119 keywords (MUST, SHOULD, MAY) correctly
225
+ - Be precise and unambiguous
226
+ - Use examples to clarify complex rules
227
+ - Keep language concise but complete
228
+ - Use active voice where possible
229
+
230
+ ### Formatting
231
+
232
+ - Use proper markdown formatting
233
+ - Include code blocks with language hints
234
+ - Use section numbering consistently
235
+ - Add cross-references to related sections
236
+ - Keep line length reasonable (80-120 characters)
237
+
238
+ ### Examples
239
+
240
+ - Show both input and output
241
+ - Include edge cases
242
+ - Demonstrate both valid and invalid cases
243
+ - Add comments explaining non-obvious behavior
244
+
245
+ ## Questions?
246
+
247
+ If you have questions about contributing:
248
+
249
+ 1. Check existing issues and discussions.
250
+ 2. Open a new issue with the `question` label.
251
+ 3. Reach out to maintainers.
252
+
253
+ ## Code of Conduct
254
+
255
+ Be respectful and constructive in all interactions. We're building this specification together, and diverse perspectives make it better.
256
+
257
+ ## License
258
+
259
+ By contributing to this specification, you agree that your contributions will be licensed under the MIT License.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025-PRESENT Johann Schopplich
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,111 @@
1
+ # TOON Format Specification
2
+
3
+ [![SPEC v1.3](https://img.shields.io/badge/spec-v1.3-lightgrey)](./SPEC.md)
4
+ [![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](./LICENSE)
5
+
6
+ This repository contains the official specification for **Token-Oriented Object Notation (TOON)**, a compact, human-readable serialization format designed for passing structured data to Large Language Models with significantly reduced token usage.
7
+
8
+ ## ๐Ÿ“‹ Specification
9
+
10
+ [โ†’ Read the full specification (SPEC.md)](./SPEC.md)
11
+
12
+ - **Version:** 1.3 (2025-10-31)
13
+ - **Status:** Working Draft
14
+ - **License:** MIT
15
+
16
+ The specification includes complete grammar (ABNF), encoding rules, validation requirements, and conformance criteria.
17
+
18
+ ## What is TOON?
19
+
20
+ **Token-Oriented Object Notation** is a compact, human-readable serialization format designed for passing structured data to Large Language Models with significantly reduced token usage. It's intended for LLM input, not output.
21
+
22
+ TOON's sweet spot is **uniform arrays of objects** โ€“ multiple fields per row, same structure across items. It borrows YAML's indentation-based structure for nested objects and CSV's tabular format for uniform data rows, then optimizes both for token efficiency in LLM contexts. For deeply nested or non-uniform data, JSON may be more efficient.
23
+
24
+ **Key Features:**
25
+
26
+ - ๐Ÿ’ธ **Token-efficient:** typically 30โ€“60% fewer tokens than JSON
27
+ - ๐Ÿคฟ **LLM-friendly guardrails:** explicit lengths and fields enable validation
28
+ - ๐Ÿฑ **Minimal syntax:** removes redundant punctuation (braces, brackets, most quotes)
29
+ - ๐Ÿ“ **Indentation-based structure:** like YAML, uses whitespace instead of braces
30
+ - ๐Ÿงบ **Tabular arrays:** declare keys once, stream data as rows
31
+
32
+ ## Quick Example
33
+
34
+ **JSON:**
35
+
36
+ ```json
37
+ {
38
+ "users": [
39
+ { "id": 1, "name": "Alice", "role": "admin" },
40
+ { "id": 2, "name": "Bob", "role": "user" }
41
+ ]
42
+ }
43
+ ```
44
+
45
+ **TOON:**
46
+
47
+ ```
48
+ users[2]{id,name,role}:
49
+ 1,Alice,admin
50
+ 2,Bob,user
51
+ ```
52
+
53
+ ## Reference Implementation
54
+
55
+ The reference implementation in TypeScript/JavaScript is maintained at: [github.com/toon-format/toon](https://github.com/toon-format/toon)
56
+
57
+ The reference implementation includes:
58
+
59
+ - Complete encoder and decoder
60
+ - CLI tools for JSON โ†” TOON conversion
61
+ - Performance benchmarks
62
+
63
+ ## Community Implementations
64
+
65
+ Official community-driven implementations are currently being developed at the [github.com/toon-format](https://github.com/toon-format) organization.
66
+
67
+ ## Test Fixtures & Conformance
68
+
69
+ The [tests/fixtures/](./tests/fixtures/) directory contains **language-agnostic JSON test fixtures** for validating TOON implementations. Each fixture file contains test cases with input/output pairs covering all specification requirements.
70
+
71
+ **What's included:**
72
+
73
+ - **Encoding tests:** JSON โ†’ TOON conversion
74
+ - **Decoding tests:** TOON โ†’ JSON parsing
75
+ - **Error cases:** Validation and strict mode checks
76
+ - **Edge cases:** All corner cases from the specification
77
+
78
+ **For implementers:**
79
+
80
+ 1. Load JSON fixtures from `tests/fixtures/encode/` and `tests/fixtures/decode/`.
81
+ 2. Run each test case against your implementation.
82
+ 3. Report results using the conformance badge system.
83
+
84
+ See [tests/README.md](./tests/README.md) for detailed fixture format and usage instructions.
85
+
86
+ ## Contributing
87
+
88
+ We welcome contributions to improve the specification! Please see [CONTRIBUTING.md](./CONTRIBUTING.md) for:
89
+
90
+ - How to propose spec changes
91
+ - The RFC process for major changes
92
+ - Guidelines for submitting issues and pull requests
93
+
94
+ For implementation-specific questions or bugs, please refer to the respective implementation repository.
95
+
96
+ ## Versioning
97
+
98
+ The TOON specification follows semantic versioning. See [VERSIONING.md](./VERSIONING.md) for our versioning policy and compatibility guarantees.
99
+
100
+ ## Resources
101
+
102
+ - **Specification:** [SPEC.md](./SPEC.md) - Complete formal specification with ABNF grammar
103
+ - **Examples:** [examples/](./examples/) - Working examples organized by feature
104
+ - **Test Fixtures:** [tests/fixtures/](./tests/fixtures/) - Comprehensive test suite
105
+ - **Changelog:** [CHANGELOG.md](./CHANGELOG.md) - Version history and changes
106
+ - **Reference Implementation:** [github.com/toon-format/toon](https://github.com/toon-format/toon) - TypeScript/JavaScript implementation
107
+ - **Benchmarks:** [Reference repo benchmarks/](https://github.com/toon-format/toon/tree/main/benchmarks) - Token efficiency measurements and accuracy retrieval tests
108
+
109
+ ## License
110
+
111
+ [MIT](./LICENSE) License ยฉ 2025-PRESENT [Johann Schopplich](https://github.com/johannschopplich)