
KDnuggets
· 1 min read
What’s Actually Inside 24,723 Tokens of a Search Result? We Broke It Down, Field by Field
It's no secret that AI agents burn massive amounts of tokens on search results and file retrievals. They pull in dozens of full-length files, logs, and comment blocks, and just reading through those matches can consume tens of thousands of tokens, not to mention the recursive loops that lock in when the agent reruns a query.
Just a simple search like "look up coffee shops" can balloon into a payload of nested objects, tracking links and metadata. Much of this data never even gets used by the model. You still wind up paying for each token. However, there are ways to minimize token usage.
SerpApi now offers Markdown output that supports a radical trimming of token sizes. Using conventional JavaScript Object Notation (JSON), a search for "coffee" resulted in a response that required 24,723 tokens. Using Markdown, the same search only used 6,435 tokens. That's a 74 percent reduction and there is more to be gained, as further filtering can require just 1,298 tokens for a more restricted view. That reduction can make the AI model more efficient, reduce costs, or allow other information to stay in the context window.
JSON vs. Markdown
But how does it work? SerpApi's Markdown output retains the informational content but strips or reshapes the parts that inflate token count without helping a model reason. Based on SerpApi's documentation and examples, here’s what typically gets removed or transformed:
SerpApi has not published an exact token cost per field; the before-and-after totals (from 24,723 to 6,435) are authoritative numbers. The pattern, however, is clear: anything that exists for code to parse or a UI to render, but not for a model to read, is prime token waste.
Where Markdown Isn’t the Right Fit
How SerpApi Solves It
SerpApi addresses this directly with a single switch, available through a query parameter, route extension, or header. You can request Markdown output by:
Original source
This story was published by KDnuggets and written by KDnuggets. SyncAI.news shows a preview; the complete article is on the publisher's site.
Read the full story on kdnuggets.com


