Token Cost Engineering · 9 / 13

Syntax Layer: Prompts Are Written for Machines

First of the four hands-on layers. Early products often keep ###, bold **, and pretty JSON—either for debugging or because an AI drafted the prompt. Layout that feels friendly to humans is “lexical tax” in an LLM's billing logic.

lexical taxYAMLCSVMinified JSON
How heavy is this tax: 13% is formatting

The author built a Token visualization tool (yusuan.ai/analyzer) and dropped in a slim Lyra prompt: bold ** alone ate 8.5% of Tokens. Add list markers, heading symbols, JSON indentation and newlines, and 13% of that prompt is formatting. In typical product Prompts, 10%–20% is this kind of decorative Token.

Token visualization: ** appears 33 times at 4.16%
Token visualization (yusuan.ai/analyzer): ** appears 33 times in one prompt—that single symbol is 4.16%. (Figure: from the author's internal share deck)
Decorative Tokens at 10%–20%
At tens-of-millions call volume, 10%–20% of the monthly budget goes to “making PMs feel a little more comfortable.” (Figure: from the author's internal share deck)
A Prompt is an instruction for machines—the final version doesn't need to look pretty. Machines care about logic, not layout. Use ** only where emphasis is truly needed.
Interactive Demo · Three bills for the same data

Feed the model 50 user records and compare three formats. A JSON array that repeats field names 50 times is the RAG disaster zone.

Three rules of thumb

1. Complex objects: YAML (or TOON), not JSON. JSON's signal-to-noise is awful: every key wrapped in quotes, every nesting level closed with braces—and those symbols often bill as their own Tokens. YAML uses indentation instead of closers and a colon instead of “quotes+colon,” usually saving 10%–15%, sometimes up to 40%. TOON is a new format built to save Tokens, but LLMs may not support it well yet—so the steadier combo is YAML + CSV.

2. Flat lists: CSV, not JSON arrays. A headered table kills repeated key names. Long-list scenarios cut 30%–60%, and the same context window holds more data.

JSON array vs CSV table
Write key names once, kill every repeat: long lists save 30%–60% Tokens outright. (Figure: from the author's internal share deck)

3. Backend output: force Minified JSON. Output Tokens cost more than input, and they slow the API return. Streaming to users can stay looser, but pure backend jobs (tag extraction, sentiment, cleaning) need zero layout—spell it out in the System Prompt:

Output must be Minified JSON—no newlines, no indentation, no code-fence markers. Example: {"id":1,"status":"ok"}

Machines reading data need validity, not beauty. Add this constraint to batch jobs and generation time drops noticeably.

Key Takeaways

Measure your Prompt on yusuan.ai/analyzer first: decorative Tokens usually take 10%–20%—the easiest money you'll reclaim.

Pick data shape by scenario: YAML for complex objects, CSV for flat lists, Minified JSON for backend output.

Output costs more than input, so locking output format saves money and latency (lesson 12 has three more moves).

Source: Adapted from the author's internal team share “AI Token Cost Engineering Strategies,” hands-on section “01|Syntax Layer.” Tool: yusuan.ai/analyzer; YAML spec at yaml.org.