What’s Actually Inside 24,723 Tokens of a Search Result? We Broke It Down, Field by Field

The Anatomy of Token Bloat in Agentic Systems
In modern AI agent architecture, the process of retrieval-augmented generation (RAG) involves fetching data from external APIs to inform the model’s output. Developers typically utilize JSON, the industry standard for data interchange, because of its strict typing and ease of programmatic parsing. However, for an LLM that is tasked with synthesizing information rather than executing database operations, the verbose syntax of JSON is often counterproductive.
A typical search query returned in JSON format includes extensive nesting, repeated key names, and boilerplate metadata intended for frontend web browsers rather than AI logic. These tokens—each representing a segment of the data stream—are expensive. In many enterprise-scale deployments, the cost of processing a single query is multiplied by the number of files and search results an agent must read, often leading to recursive loops where the model consumes thousands of tokens just to navigate the structure of the data itself.
Recent data from industry benchmarks illustrates the severity of this issue. A standard search query for common retail goods, when rendered in JSON, can require upwards of 24,000 tokens per request. By contrast, migrating that same information into a condensed Markdown format can reduce the token requirement to approximately 6,400 tokens. This represents a 74 percent reduction in data volume. When combined with server-side field restriction techniques, that number can drop further to roughly 1,300 tokens, yielding a massive improvement in efficiency without sacrificing the semantic quality of the search results.
Chronology of the Shift Toward Model-First Data Formats
The evolution of data delivery for AI has followed a distinct path. In the early days of API development, JSON was the undisputed king because it catered to software engineers building web applications. By 2022 and 2023, as LLMs became the primary consumers of API data, the "JSON-first" approach began to show signs of strain.
- 2022: The rapid adoption of ChatGPT and similar models forced developers to realize that their existing scraping and API infrastructure was ill-equipped for AI. Developers began manually stripping JSON responses to save context window space.
- Early 2023: Custom scripts and complex parsing logic emerged as a "middle-ware" layer to transform API responses into text or Markdown before feeding them into prompts.
- Late 2023 to 2024: API providers, recognizing the market demand for cost-effective AI integration, began to bake model-specific output formats directly into their infrastructure. SerpApi, for instance, introduced native Markdown support as a core feature, moving the transformation process from the client-side to the server-side to eliminate unnecessary data transfer.
Understanding the Trade-off: JSON vs. Markdown
The choice between JSON and Markdown is not merely stylistic; it is a fundamental architectural decision that depends on the downstream consumer. JSON remains the superior choice for programmatic pipelines that require strict data integrity. If an application must calculate average ratings based on a float value or extract pricing data to trigger an automated purchase, the structured nature of JSON ensures that the machine can interpret the data with 100 percent accuracy.

Conversely, Markdown is optimized for the LLM’s attention mechanism. By converting a search result into a human-readable table or list, the data becomes more "natural" for the model to process. LLMs are trained on massive corpora of text that heavily utilize Markdown for formatting; consequently, the model can interpret Markdown-structured data more efficiently than deeply nested JSON objects. The removal of brackets, quotes, and extraneous metadata allows the model to allocate more of its limited context window to the actual content, such as product descriptions, reviews, and store information.
Technical Implications of Server-Side Trimming
One of the most effective ways to mitigate token costs is to perform "trimming" before the data ever leaves the provider’s server. SerpApi’s implementation of Markdown output is a prime example of this strategy. By providing a query parameter—such as output=md—the provider handles the heavy lifting of data cleanup.
Internal tracking noise, duplicate fields, and session-specific metadata are stripped away before the request completes. This approach offers two significant advantages:
- Network Latency: Smaller payloads result in faster transmission times, which is critical for real-time AI agents that need to provide instantaneous feedback.
- Cost Efficiency: Because the billing for most LLM providers is tied directly to the number of input tokens, reducing the payload size leads to immediate, measurable reductions in operational expenses.
Beyond Markdown, the use of json_restrictor tools allows developers to define an allow-list of fields. By explicitly requesting only the keys necessary for the task—such as title, snippet, and link—the developer can ensure that no "garbage" data reaches the model. This level of granular control is increasingly viewed as a best practice in AI engineering.
Broader Impact on Enterprise AI Strategy
The economic implications for businesses running large-scale agentic systems are substantial. For a company running millions of AI queries per month, a 70 to 90 percent reduction in token usage for search-related tasks translates into significant annual savings. However, the impact extends beyond the balance sheet.
By maximizing the efficiency of the context window, developers can fit more information into a single prompt. This enables agents to perform more complex multi-step reasoning, as they are no longer forced to "truncate" or ignore parts of the search results to stay within the model’s token limits. In effect, data optimization directly enhances the intelligence and reliability of the AI agent.

Industry analysts suggest that we are entering a phase where the "data shape" is as important as the data quality. As LLMs become more ubiquitous, API providers are expected to standardize these model-friendly formats. The goal is to create a frictionless environment where developers no longer need to write custom parsing scripts to "clean" data for AI. Instead, the data will be delivered in the exact format requested, optimized for the specific persona—be it a human developer, a database, or an AI agent.
Evaluating Your Own Workflow
To determine if your systems are suffering from token bloat, developers are encouraged to conduct a "delta analysis." This involves taking a representative sample of your current API calls, converting the output to Markdown, and performing a side-by-side count of the tokens consumed.
The results often reveal a staggering amount of wasted spend. For example, if a developer is pulling search results for a research agent, they might find that the agent is currently paying for thousands of tokens worth of "internal site navigation links" or "CSS classes" that provide zero value to the research objective. By identifying these patterns and implementing server-side restrictions, engineering teams can optimize their workflows to be more cost-effective and performant.
In conclusion, as the AI landscape matures, the focus must shift toward the efficiency of the data lifecycle. Markdown is not a universal replacement for JSON, but it is a powerful tool in the arsenal of any developer seeking to scale AI applications sustainably. By aligning data delivery formats with the strengths of the target LLM, developers can achieve a better balance between cost, performance, and the overall quality of their AI-driven outputs. The era of blindly piping raw API responses into LLMs is coming to a close, replaced by a more precise, intentional approach to data management.







