Special Topic · Token Cost Engineering: Make the Numbers Work

Syntax Layer: Prompts Are Written for Machines

Bold ** alone eats 8.5% of Tokens; YAML for complex objects, CSV for flat lists, force Minified JSON on backend output

THE QUESTION THIS PAGE ANSWERS

ANSWER FIRST

What is the key idea behind “Syntax Layer: Prompts Are Written for Machines”?

Bold ** alone eats 8.5% of Tokens; YAML for complex objects, CSV for flat lists, force Minified JSON on backend output

DECISION RULE

Read cost as a shape, not a single number. Break a request into input, output, retries, tools, and waiting time. The shape of usage usually tells you which design choice is expensive and where a smaller change can help.

TRY NEXT

Measure one real request before you optimize an imagined average.

WATCH FOR

A cheaper call that quietly creates more retries, latency, or review work.

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.

The complete interaction cost of “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 .” is a reminder that AI cost is not one price multiplied by one call. Input, output, retries, tools, waiting time, and human cleanup together decide what a task really costs.

Find what the bill repeats

The key variables behind “Feed the model 50 user records and compare three formats.” are usually repeated context, oversized output, retries after failure, and calls that do not produce useful progress. Removing wasted Tokens can reduce cost, latency, and concurrency pressure at the same time.

A cheaper call can make the whole workflow more expensive

Start with “Output costs more than input, so locking output format saves money and latency (lesson 12 has three more moves)” and keep a small table for input, output, retries, tools, and human review. Compare quality before and after optimizing instead of looking at one price in isolation.

From “How heavy is this tax: 13% is formatting” to “Interactive Demo · Three bills for the same data”

“How heavy is this tax: 13% is formatting” grounds the problem in “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%…”. “Interactive Demo · Three bills for the same data” then moves it toward “Feed the model 50 user records and compare three formats. A JSON array that repeats field names 50 times is the RAG disaster zone”. Together, they show that the lesson is not just a conclusion to remember, but a claim with conditions.

Carry the judgment into the next situation

When analyzing cost, map the complete interaction first, then find repeated input, wasted output, and retries. A cheap individual call does not make the whole task cheap.

  • “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%…
  • “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
  • “The closing point”: Pick data shape by scenario: YAML for complex objects, CSV for flat lists, Minified JSON for backend output

The final “The closing point” brings the discussion to “Pick data shape by scenario: YAML for complex objects, CSV for flat lists, Minified JSON for backend output”. The useful thing to carry forward is knowing which judgments must be revisited when input, scale, or risk changes.

Mark as learned Your reading progress updates automatically
← PreviousNext →

Keep reading

The next useful article in the thread.

ARTICLE DISCUSSION

Leave one useful thought here.

Keep the idea that clicked, the question that stayed open, or a small note for the next learner.

Discussing Syntax Layer: Prompts Are Written for Machines Token Cost Engineering: Make the Numbers Work
3discussionsArticle discussion · synced with the Circle
View in the learning circle
AM
Asha MorganContent editor
INSIGHTField note

I turned one judgment from this article into a small experiment I could run today. Knowing what to observe next is more useful than simply remembering the conclusion.

ARTICLE DISCUSSION7 helpful
LH
Lin HarperIndie developer
INSIGHTInsight

After reading this, I first looked for the conditions behind the idea instead of copying the method into a project. That order made the later trade-offs much clearer.

ARTICLE DISCUSSION5 helpful
KM
Kiki MooreProduct operations
QUESTIONQuestion

When this judgment reaches real work, which constraint should be added first? I am curious which step matters most between reading and the first practical attempt.

ARTICLE DISCUSSION4 helpful