toon-format
When working with JSON data in LLM prompts (especially large arrays or tabular data), consider the token-efficient TOON (Token-Oriented Object Notation) format which reduces tokens by 30-70% while maintaining lossless JSON representation and structural validation. Use for reading/writing .toon files, converting JSON↔TOON, or optimizing structured data for LLM consumption with guardrails like [N] counts and {field} headers.
Best use case
toon-format is best used when you need a repeatable AI agent workflow instead of a one-off prompt.
When working with JSON data in LLM prompts (especially large arrays or tabular data), consider the token-efficient TOON (Token-Oriented Object Notation) format which reduces tokens by 30-70% while maintaining lossless JSON representation and structural validation. Use for reading/writing .toon files, converting JSON↔TOON, or optimizing structured data for LLM consumption with guardrails like [N] counts and {field} headers.
Teams using toon-format should expect a more consistent output, faster repeated execution, less prompt rewriting.
When to use this skill
- You want a reusable workflow that can be run more than once with consistent structure.
When not to use this skill
- You only need a quick one-off answer and do not need a reusable workflow.
- You cannot install or maintain the underlying files, dependencies, or repository context.
Installation
Claude Code / Cursor / Codex
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/toon-format/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How toon-format Compares
| Feature / Agent | toon-format | Standard Approach |
|---|---|---|
| Platform Support | Not specified | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | Unknown | N/A |
Frequently Asked Questions
What does this skill do?
When working with JSON data in LLM prompts (especially large arrays or tabular data), consider the token-efficient TOON (Token-Oriented Object Notation) format which reduces tokens by 30-70% while maintaining lossless JSON representation and structural validation. Use for reading/writing .toon files, converting JSON↔TOON, or optimizing structured data for LLM consumption with guardrails like [N] counts and {field} headers.
Where can I find the source code?
You can find the source code on GitHub using the link provided at the top of the page.
SKILL.md Source
# TOON Format Skill
TOON (Token-Oriented Object Notation) is a compact, human-readable, schema-aware encoding of JSON designed to be easy for LLMs to *read* and (with good prompting) to *generate*. It is especially effective for **uniform arrays of objects** (tabular data), where keys are declared once and rows carry values.
## Quick decision: should I use TOON?
Use TOON when:
- You are passing **large structured context** (especially arrays of objects) to an LLM and want fewer tokens.
- You want **structure guardrails** (`[N]` counts + `{fields}` headers) to reduce model drift and enable validation.
- You need a format that stays close to CSV’s readability but is a **lossless representation of JSON**.
Prefer JSON (or JSONL/CSV) when:
- You need interoperability with systems that expect standard JSON.
- Data is extremely irregular (ragged objects) and the TOON representation won’t be more compact or readable.
- The task is primarily “machine ↔ machine” with no human/LLM in the loop.
For more detail: see [reference/when-to-use.md](reference/when-to-use.md).
## Core patterns you must follow
### 1) Recognize TOON in the wild
TOON commonly looks like:
- Scalars/objects as `key: value` / indented blocks
- Arrays with lengths: `users[3]: ...`
- Tabular arrays with field headers: `users[3]{id,name,role}:`
- Rows are delimiter-separated (comma by default; tab often best)
### 2) Converting JSON ↔ TOON (recommended paths)
#### A) CLI (fastest, good for pipelines)
Use the official CLI for round-tripping and stats.
**Encode JSON → TOON**
```bash
npx @toon-format/cli input.json -o output.toon
```
**Decode TOON → JSON**
```bash
npx @toon-format/cli input.toon -o output.json
```
**Token stats + maximum efficiency**
```bash
npx @toon-format/cli input.json --delimiter "\t" --stats -o output.toon
```
**Optional structure compression**
- Key folding (encode): `--keyFolding safe`
- Path expansion (decode): `--expandPaths safe`
For full CLI options and examples: see [reference/cli.md](reference/cli.md).
#### B) TypeScript/JavaScript library
Use `@toon-format/toon` for in-app encode/decode. See [reference/library.md](reference/library.md).
### 3) Prompting patterns for LLMs (critical)
When sending TOON as input:
- **Show, don’t explain.**
- Wrap data in a fenced code block labeled `toon` (or `yaml` if needed):
- ```toon
- (TOON data)
- ```
When asking for TOON output:
- Provide the **expected header template** (e.g., `users[N]{id,name,role}:`)
- Explicit rules:
- 2-space indent
- `[N]` must match row count
- no extra commentary; output only the code block (if you need strict parsing)
For proven prompt patterns and pitfalls: see [reference/llm-prompting.md](reference/llm-prompting.md).
### 4) Always validate model-generated TOON
If the model outputs TOON, you MUST validate it (strict mode by default in official tooling). If validation fails:
- Ask for re-output with the same header template
- Or fall back to JSON output
## Minimal working examples
### Example: filter rows (LLM output expected as TOON)
**Input**
```toon
users[3]{id,name,role,lastLogin}:
1,Alice,admin,2025-01-15T10:30:00Z
2,Bob,user,2025-01-14T15:22:00Z
3,Charlie,user,2025-01-13T09:45:00Z
```
**Instruction**
Return only users with role "user" as TOON. Use the same header format. Set `[N]` correctly. Output only the code block.
---
## Utilities included in this Skill
- `scripts/toon_convert.py`: A convenience wrapper that:
- detects TOON code fences in Markdown and extracts them
- calls the official CLI via `toon` (if installed) or `npx @toon-format/cli`
- supports `--encode/--decode`, `--delimiter`, `--stats`, and folding/expansion flags
See: [scripts/README.md](scripts/README.md)Related Skills
transformation-workflow
Practical application guide for HUMMBL's 6 transformations (Perspective, Inversion, Composition, Decomposition, Recursion, Meta-Systems). Includes when to use each transformation, combination patterns, analysis templates, output formats, real-world examples, and common pitfalls. Essential for applying mental models effectively in problem-solving and analysis.
tool-call-file-parameter-formatting
Formats file and URL parameters for tool calls. You must analyze the target tool's parameter names and descriptions to choose the correct format (base64, text, or URL ref).
parallel-task-format
Compact YAML format for defining parallel task specifications with scope, boundaries, and agent assignments. Use when creating task files for parallel development.
format-figure
Reformats a figure component file to conform to the standard section order and naming conventions defined in the figure guidelines.
format-euler-code
Enforce the Euler repository C++ formatting and style rules from AGENTS.md. Use when writing, editing, or reviewing Euler solution code so it matches required includes, types, layout, namespaces, and I/O conventions.
Fixed Video Format (9:16)
Fixed 1080x1920 pixel video format with percentage-based positioning. Use this when laying out video compositions, positioning elements on the canvas, or calculating dimensions. All videos render at exactly 9:16 aspect ratio for TikTok/Instagram Reels.
code_formatter
Otomatik kod formatlama, Prettier/ESLint entegrasyonu ve kod stil tutarlılığı rehberi.
architecture-format-extended
Extended architecture templates with full examples. Imports architecture-format-core for base structure.
actionable-review-format-standards
Standardized output format for code reviews with severity labels, file:line references, and fix code snippets. Use when generating review reports that need consistent, actionable feedback structure.
1k-date-formatting
Date and time formatting for OneKey applications. Use when displaying dates, timestamps, or formatting time in UI components. Always use OneKey utilities instead of native JS date methods. Triggers on date, time, timestamp, formatDate, formatTime, toLocaleDateString, toLocaleString, dateUtils, locale, format, display date, show time, datetime, calendar.
dbt-transformation-patterns
Master dbt (data build tool) for analytics engineering with model organization, testing, documentation, and incremental strategies. Use when building data transformations, creating data models, or ...
verify-information-rule
This rule ensures that the AI always verifies information before presenting it, avoiding assumptions and speculation.