Should you use JSON or Markdown when feeding search data to AI agents?

by

JSON is the industry standard for APIs, but is it actually the best format for a language model? We did a deep dive into possible advantages when using Markdown and the short answer is that JSON is costing you a lot of unnecessary tokens. JSON is full of nested braces, trailing commas, and strict structural noise. LLMs do not need this to understand the data.

Why Markdown?

Markdown tables and native links like [title](url) pack the exact same informational data as nested JSON but with a fraction of the character weight. On average, switching to Markdown cuts token usage by 50%.

On complex API endpoints with heavy nested layers, the savings can be even wilder:

  • Google Search: up to 74% token savings

  • Google Shopping: up to 90% token savings

  • Apple Maps: up to 91% token savings

Standard JSON search responses frequently include duplicate fields, opaque internal tracking tokens, and redirect parameters. Passing these to an LLM slows down inference speed and drives up costs.

SerpApi Markdown Output

To solve this, our team at SerpApi is officially launching a native Markdown Output feature for all of our APIs. You just add `output=md` to the search options or hit the `/` route and the savings can start!

36 views

Add a comment

Replies

Be the first to comment