The Cost of Pretty JSON
JSON was designed for application-to-application interchange — readability for developers, clarity for debugging. When an AI agent reads a tool response, it processes the same structural characters that make JSON readable: quotation marks around every key and string value, braces around every object, brackets around every array, commas between every element, and whitespace for indentation.
Each of those characters is a token. In a production agent workflow where tool responses flow through the context window hundreds or thousands of times a day, the overhead is substantial. Research on MCP workloads across 22 teams in Q1 2026 found that MCP-related input tokens accounted for 41 to 58 percent of total Claude Code spend. [1] Poor data serialization can consume 40-70% of available tokens in production agent systems before any meaningful reasoning begins. [2]
The simplest optimization — the one you can do in five minutes — is to stop pretty-printing JSON in tool responses.
Minified JSON: The Five-Minute Win
Switching from indented JSON to compact JSON is the highest-ROI optimization available. In most languages, it's a one-line change. In Python: json.dumps(obj, separators=(",", ":")) instead of the default json.dumps(obj, indent=2). In JavaScript: JSON.stringify(obj) without the pretty-print arguments.
The results are measurable. Benchmarks on a mid-sized Home Assistant installation show compact JSON is 31% smaller than indent=2 and 18% smaller than the standard library default. On a full entity list of 1,000-2,000 items, that translates to roughly 100,000 tokens saved per call. [3]
This is not a tradeoff. The model doesn't need indentation to parse JSON — it tokenizes the content the same way regardless of whitespace. You lose nothing in comprehension and gain significant cost reduction. If your MCP servers or tool responses are returning pretty-printed JSON, fix that first before considering anything more exotic.
Beyond Minification: Token-Optimized Formats
Compact JSON removes whitespace but retains all of JSON's structural syntax — quotes around every key, braces around every object, commas between every element. A new generation of formats targets that structural overhead directly.
TRON: Token Reduced Object Notation
TRON is a superset of JSON — meaning any valid JSON is also valid TRON — that reduces token count by allowing "class" definitions (schemas) for objects. Instead of repeating property names in every object in an array, you define the schema once and encode subsequent objects as positional values. This eliminates the key repetition that dominates large JSON arrays.