datoon
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
Raw structured data is often verbose in LLM prompts. TOON can save tokens — but blind conversion can also make payloads worse. datoon adds a decision layer: convert when structure and savings justify it, skip when they don't, and always explain why.
Supports JSON, CSV, JSONL, YAML, XML, Parquet, Avro, ORC, Excel, and Apple Numbers — auto-detected from file extension.
Before / After
JSON in the prompt (42 tokens)
{"users":[
{"id":1,"name":"Ada","role":"admin"},
{"id":2,"name":"Lin","role":"analyst"},
{"id":3,"name":"Grace","role":"viewer"}
]}datoon converts → TOON (35 tokens)
users[3]{id,name,role}:
1,Ada,admin
2,Lin,analyst
3,Grace,viewer{"decision":"convert","reason":"Estimated savings 16.67% (threshold 15.00%)."}CSV from a data pipeline (40 tokens as JSON)
id,name,role
1,Ada,admin
2,Lin,analyst
3,Grace,viewerdatoon auto-converts → TOON (34 tokens)
datoon data.csv --report-stdoutSame rows as TOON. Zero JSON serialization in your code.
Non-uniform payload (14 tokens)
{"config":{"debug":true},"tags":["a","b"]}datoon skips → keeps JSON
{"decision":"skip","reason":"No uniform object arrays found with at least 3 rows."}No silent corruption.
Same data. Right format. Always explained.
Token counts on this page come from tiktoken:o200k_base. Three rows barely clear the 15% threshold; savings grow with the table. Uniform payloads in the benchmarks save 22–28%, and 100–300-row query results cost Claude about half the input tokens of JSON objects.
datoon savespayload tokens — the structured data portion of your prompt. Token savings depend on payload shape: uniform tabular data converts well; deeply nested or non-uniform structures are skipped. Every decision includes a reason so pipelines can log, debug, and trust the outcome.
Related MCP server: mcp-json-yaml-toml
Install
# core (JSON, CSV, JSONL, XML — no extra deps)
uv add datoon
pip install datoon
# with YAML support
pip install "datoon[yaml]"
# with Excel support
pip install "datoon[excel]"
# with Parquet / ORC / Avro support
pip install "datoon[columnar]"
# with Apple Numbers support
pip install "datoon[numbers]"
# with tiktoken-based token counting
pip install "datoon[tokens]"
# with Claude token counting (Anthropic API) / Hugging Face tokenizers
pip install "datoon[claude]"
pip install "datoon[hf]"
# everything
pip install "datoon[all]"Requires Python 3.12+. TOON conversion is pure Python (official toon-format encoder, installed automatically) — no Node.js needed.
For the Claude Code plugin and Codex → INSTALL.md.
What You Get
What | |
| Auto-gate any supported format → TOON from terminal or scripts |
Python API |
|
Claude Code Plugin |
|
Codex Plugin | Marketplace plugin — structured-data mode for Codex |
Supported input formats
Format | Extension | Extra needed |
JSON |
| — |
JSONL |
| — |
CSV |
| — |
XML |
| — |
YAML |
|
|
Excel |
|
|
Parquet |
|
|
Avro |
|
|
ORC |
|
|
Apple Numbers |
|
|
How It Works
Detect format — from
--formatflag, file extension, or default to JSON for stdinRead + normalize — parse source into list of row dicts; serialize to compact JSON
Analyze structure — uniform object arrays? acceptable depth? minimum rows?
Gate early — non-candidates skip before any TOON encoding
Convert + estimate — TOON encoder runs in-process, token savings calculated
Gate savings — below threshold → return JSON; above → return TOON with report
Every path returns a ConversionReport with decision, reason, token estimates, and the tokenizer that produced them. Pipelines never get silent surprises.
Choosing a tokenizer
Token estimates drive the savings gate, so pick the counter that fits the job. Pass one spec with --tokenizer, ConversionConfig(tokenizer=...), or the DATOON_TOKENIZER environment variable; in Python any callable str -> int works too.
Spec | Counts with | Needs |
|
| — |
|
| — |
| tiktoken, default |
|
| Anthropic token counting API for that model |
|
| Hugging Face |
|
a callable (Python) | your own function, reported as | — |
Use the local counters (auto, chars, tiktoken) to gate payloads at runtime: they are fast and run locally (tiktoken fetches its encoding file once on first use). Use claude: or hf: in benchmarks and evals where counts for the target model matter. claude: makes network calls, and Anthropic documents its counts as estimates. Only auto falls back silently: an explicit spec with a missing package fails with an error that names the extra to install, and claude: without Anthropic credentials fails too. Every report records the resolved name in tokenizer.
Quick Start
JSON (stdin):
echo '{"users":[{"id":1,"name":"Ada"},{"id":2,"name":"Lin"},{"id":3,"name":"Grace"}]}' | datoon --report-stdoutCSV (auto-detected from extension):
datoon data.csv --report-stdoutJSONL:
datoon data.jsonl -o output.toonYAML (requires datoon[yaml]):
datoon data.yaml --report-stdoutParquet (requires datoon[columnar]):
datoon data.parquet --report ./report.jsonExplicit format override:
datoon --format csv < data.csv --report-stdoutForce conversion (bypass gating — for experiments):
datoon data.json --force --report-stdoutPython API
JSON conversion:
from datoon import convert_json_for_llm, ConversionConfig, DatoonError
config = ConversionConfig(min_savings_ratio=0.15, max_depth=6, min_uniform_rows=3)
try:
outcome = convert_json_for_llm(raw_json, config)
except DatoonError as exc:
raise
# outcome.payload_text — TOON or original JSON
# outcome.report.decision — "convert" | "skip"
# outcome.report.reason — human-readable explanation
send_to_model(outcome.payload_text)Any format via read_tabular:
from pathlib import Path
from datoon import read_tabular, convert_data_for_llm
# text formats: csv, jsonl, yaml, xml
rows = read_tabular("csv", text=csv_string)
# binary formats: excel, parquet, orc, avro, numbers
rows = read_tabular("parquet", path=Path("data.parquet"))
# takes Python data directly; dates, decimals and bytes are serialised for you
outcome = convert_data_for_llm(rows)
send_to_model(outcome.payload_text)Structure-only analysis:
from datoon.analyzer import analyze_payload
from datoon.models import ConversionConfig
analysis = analyze_payload(parsed_data, ConversionConfig())
print(analysis.is_candidate, analysis.reason)Claude Code Plugin
Install directly from GitHub:
claude plugin marketplace add andrii-su/datoon
claude plugin install datoon@datoonTrigger in-session:
/datoon
convert this JSON to TOON if it saves tokens
use datoon mode for structured dataCLI Reference
Flag | Default | Description |
| auto | Input format: |
|
| Bypass gating and minimum savings threshold |
|
| Minimum relative token savings required |
|
| Maximum nesting depth for auto-conversion |
|
| Minimum rows in uniform object arrays |
|
| Worksheet index for Excel / Numbers input |
|
| Table index within a Numbers sheet |
|
| Token counter for estimates — see Choosing a tokenizer |
| — | Write JSON conversion report to file |
| — | Print JSON conversion report to stderr |
| stdout | Output file path |
| — | Print version and exit |
Format is auto-detected from file extension. Use --format to override or when reading from stdin.
Benchmarks
PYTHONPATH=src python benchmarks/run.py --dry-run
PYTHONPATH=src python benchmarks/run.py --tokenizer tiktoken
PYTHONPATH=src python benchmarks/run.py --formats --tokenizer tiktoken --update-readmeBoth tables below are counted with tiktoken:o200k_base. The chars counter is a length heuristic and reports larger savings on the same payloads.
Auto mode against forced conversion
Forced conversion makes two of the five payloads larger (orders-nested, mixed-non-uniform). Auto mode skips those two, converts the other three, and returns a reason for every decision.
Dataset | JSON | TOON (forced) | Raw Saved | Auto | Auto Tokens | Auto Saved |
users-small | 54 | 40 | 25.9% | convert | 40 | 25.9% |
events-medium | 219 | 162 | 26.0% | convert | 162 | 26.0% |
orders-nested | 106 | 116 | -9.4% | skip | 106 | 0.0% |
mixed-non-uniform | 35 | 47 | -34.3% | skip | 35 | 0.0% |
metrics-wide | 142 | 103 | 27.5% | convert | 103 | 27.5% |
Average | 111 | 94 | 7.1% | 3/5 convert | 89 | 15.9% |
Forced conversion succeeded for 5/5 payloads.
Format conversion benchmark
Token savings when converting from common structured formats (CSV, JSONL, XML, YAML). Baseline is the JSON representation of the same data — what an LLM would receive without datoon.
Dataset | Format | JSON Tokens | TOON (forced) | Auto | Auto Tokens | Auto Saved |
users-csv | csv | 51 | 39 | convert | 39 | 23.5% |
events-jsonl | jsonl | 216 | 161 | convert | 161 | 25.5% |
catalog-xml | xml | 94 | 73 | convert | 73 | 22.3% |
metrics-yaml | yaml | 139 | 102 | convert | 102 | 26.6% |
Average | — | 125 | 94 | 4/4 convert | 94 | 24.5% |
Forced conversion succeeded for 4/4 payloads.
Reading accuracy
Fewer tokens only help if the model still reads the data correctly. benchmarks/format_eval/ gives a Claude model the same query result as JSON objects, a markdown table and TOON, then asks six questions per table with answers computed in Python (row count, cell lookup, filtered count, maximum, difference, NULL count).
24 synthetic tables of 100–300 rows and 4–30 columns, one API call per table and format. Input tokens are real API usage.
Model | Format | Correct answers | 95% interval | Input tokens vs JSON objects |
Claude Sonnet 5.5 | JSON objects | 142/144 (98.6%) | 95.1–99.6% | 100% |
Claude Sonnet 5.5 | markdown | 142/144 (98.6%) | 95.1–99.6% | 60% |
Claude Sonnet 5.5 | TOON | 143/144 (99.3%) | 96.2–99.9% | 50% |
Claude Haiku 5.5 | JSON objects | 134/144 (93.1%) | 87.7–96.2% | 100% |
Claude Haiku 5.5 | markdown | 136/144 (94.4%) | 89.4–97.2% | 60% |
Claude Haiku 5.5 | TOON | 130/138 (94.2%) | 89.0–97.0% | 50% |
The intervals overlap: these runs show no accuracy difference between formats, and TOON halves the input tokens. One Haiku TOON reply was cut off at the output limit, so its six answers are not graded. Sonnet is close to the ceiling on this set, so a 1–2 point gap between formats would go unseen.
An earlier with-skill / without-skill agent comparison is kept in benchmarks/agent_skill_eval/; its token figures predate the selectable tokenizers.
Development
Contributor workflow: CONTRIBUTING.md. Maintainer/agent notes: CLAUDE.md.
Setup:
uv sync --extra dev
uvx pre-commit installTests:
pytestSkill sync + plugin metadata:
python scripts/validate_skill_sync.py
python scripts/validate_plugin_metadata.pyLinks
INSTALL.md — full install matrix, all targets, per-agent detail
CONTRIBUTING.md — contributor workflow
CLAUDE.md — maintainer guide for agents
CHANGELOG.md — release history
SECURITY.md — vulnerability reporting
Live docs —
docs/Issues — bugs, features, questions
License
MIT
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
This server cannot be deployed
Maintenance
Related MCP Connectors
Free, no-key MCP server: token estimates, JSON Schema conversion, MCP configs, tool search.
MCP server for querying and analyzing data from ad platforms, analytics tools, and spreadsheets
Hosted MCP: CSV/XLSX to JSON rows and text-PDF pages; private uploads or URLs, no API key.
Hosted MCP server: convert PDFs to clean, LLM-ready Markdown with tables, formulas and OCR.
Related MCP Servers
- AlicenseCqualityDmaintenanceAn MCP server that provides text conversion, formatting, and analysis functions, which can be directly integrated into the development workflow.432Apache 2.0
- AlicenseAqualityCmaintenanceA token-efficient, schema-aware MCP server that enables AI assistants to safely read, modify, query, and validate JSON, YAML, and TOML files with automatic schema detection and format conversion capabilities.810MIT
- AlicenseAqualityDmaintenanceEnables users to convert structured data into Token-Oriented Object Notation (TOON) to reduce LLM token usage and costs by up to 70%. It provides tools for encoding, decoding, and analyzing data formats like JSON, CSV, and XML to optimize prompt efficiency.47 npm3MIT
- AlicenseNot gradedqualityDmaintenanceAn MCP server that provides tools for JSON validation, diffing, and transformation operations such as flattening and renaming. It also enables data format conversion between JSON, CSV, and YAML to streamline data processing for AI agents.39 npmMIT