| name | to-toon |
| description | Converts structured data (JSON, XML, YAML) to compact TOON format (Token-Oriented Object Notation) with 30-60% token savings. Use when compressing API responses, Figma MCP output, config files, or any structured data for token efficiency.
|
Universal TOON Converter
Purpose
Convert any structured data (JSON, XML, YAML) to compact TOON format for efficient LLM processing.
Quick Start
JSON → TOON (use official CLI)
npx @toon-format/cli input.json -o output.toon
echo '{"name": "Ada", "age": 30}' | npx @toon-format/cli
npx @toon-format/cli data.json --stats
TOON → JSON (decode)
npx @toon-format/cli data.toon -o output.json
XML → TOON (via JSON)
${CLAUDE_PLUGIN_ROOT}/scripts/xml-to-toon.sh input.xml
cat input.xml | node ${CLAUDE_PLUGIN_ROOT}/scripts/xml-to-json.mjs | npx @toon-format/cli
CLI Reference
npx @toon-format/cli input.json -o output.toon
npx @toon-format/cli data.toon -o output.json
cat data.json | npx @toon-format/cli
echo '{"name": "Ada"}' | npx @toon-format/cli
npx @toon-format/cli input.json
npx @toon-format/cli data.json --stats
TOON Format Overview
TOON combines YAML-like syntax with CSV-style tabular arrays:
# Key-value pairs
name: Ada
age: 30
# Nested objects
address:
city: Berlin
zip: 10115
# Uniform arrays (most compact!)
users[3]{id,name,email}:
1,Alice,alice@example.com
2,Bob,bob@example.com
3,Carol,carol@example.com
Token Savings Examples
| Input Format | JSON Tokens | TOON Tokens | Savings |
|---|
| Simple object | 50 | 30 | 40% |
| Array of 10 objects | 500 | 200 | 60% |
| Nested config | 1000 | 450 | 55% |
| Figma design context | 10000 | 4000 | 60% |
Common Use Cases
1. API Response Compression
curl -s https://api.example.com/users | npx @toon-format/cli --stats
2. Config File Compression
npx @toon-format/cli package.json --stats
npx @toon-format/cli tsconfig.json -o tsconfig.toon
3. Figma MCP Data
After get_design_context call:
${CLAUDE_PLUGIN_ROOT}/scripts/xml-to-toon.sh figma-output.xml --stats
4. Database Export
cat users.json | npx @toon-format/cli > users.toon
Included Scripts
xml-to-toon.sh
Full pipeline for XML data (Figma, HTML, SVG, etc.):
${CLAUDE_PLUGIN_ROOT}/scripts/xml-to-toon.sh input.xml
${CLAUDE_PLUGIN_ROOT}/scripts/xml-to-toon.sh input.xml -o output.toon
${CLAUDE_PLUGIN_ROOT}/scripts/xml-to-toon.sh input.xml --stats
${CLAUDE_PLUGIN_ROOT}/scripts/xml-to-toon.sh input.xml --json-only
xml-to-json.mjs
Convert XML to JSON (Node.js):
cat input.xml | node ${CLAUDE_PLUGIN_ROOT}/scripts/xml-to-json.mjs
Integration Tips
In Claude Code
When you receive structured data, consider:
- JSON data → Use
npx @toon-format/cli directly
- XML data → Use
xml-to-json.mjs then CLI
- YAML data → Convert to JSON first, then CLI
Alias (optional)
alias toon='npx @toon-format/cli'
alias xml2toon='${CLAUDE_PLUGIN_ROOT}/scripts/xml-to-toon.sh'
When NOT to Use TOON
- Very small data (< 100 tokens) - overhead not worth it
- Deeply nested non-uniform structures - JSON may be clearer
- When exact JSON format is required downstream
@read reference.md for detailed format specification and edge cases.