Skip to content
S/T
mediumauto-fixable

JSON indented for a human reader

Pretty-printing JSON in a prompt adds 20-30% tokens for whitespace nobody reads.

Indented JSON is easier for a person to scan, which is why it ends up in prompts: somebody copied it out of an API response viewer. The model parses minified JSON exactly as well.

The overhead is whitespace, and whitespace is proportional to nesting depth times line count. On a deeply nested schema it is commonly a quarter of the block. On a large embedded config it can be a third.

Minify it at the boundary rather than in the source, so the version in your repository stays readable and the version on the wire stays cheap. One `JSON.stringify(value)` without the indent argument is the whole fix.

Before
{
  "priority": {
    "type": "string",
    "enum": ["low", "high"]
  }
}
After
{"priority":{"type":"string","enum":["low","high"]}}

Check your own prompt

The analyser checks this pattern along with the other 25, prices each finding against your request volume, and hands back a rewritten prompt. It runs in your browser — nothing is uploaded.

Run the analyser

More on tools & schemas