HTML vs Markdown for AI agents: we measured the cost

HTML vs Markdown for AI agent plans: in 80 runs, plain HTML cost 1.9x the tokens and drew no diagrams. Asking for visuals is what makes it pay.

Method
Sample
10 planning tasks; 30 Markdown, 30 HTML and 20 visual HTML runs
Data
Synthetic tasks, one prompt per format, no thinking tokens
Models
Claude Sonnet 5.5 via the Anthropic API
Metric
Output tokens, generation time, cost per plan, SVG diagrams per plan

Two talks this year made the same claim five months apart: for AI agent output, HTML beats Markdown. We use HTML output every week, so we agree with the idea. But HTML vs Markdown is also a cost question, because every tag is an output token. So we measured it: 80 plans from the same model, in both formats. The result is clear, and it is not the one the talks suggest. A plain “write it as HTML” costs 1.9 times the tokens and adds nothing that Markdown could not show. The benefit comes only when you ask for what Markdown cannot do.

Two talks, one claim

In June, at Code with Claude Tokyo: Extended, Jason Schwartz of Anthropic gave the workshop How we Claude Code. He named three tools for working with long-running agents, and HTML was one of them.

Anthropic slide 'Three tools for working with long-running agents': removing ambiguity, understanding and planning with plans you can actually read in HTML, not Markdown, and integrated verification.
Jason Schwartz, Anthropic: plans you can actually read, in HTML and not Markdown.

A later slide compared the same plan in two formats.

Anthropic slide 'HTML plans are easier to read and capture more of the model's thinking'. Left: a bill splitter plan as a Markdown list. Right: the same plan as HTML cards for scope, open questions and flow.
Jason Schwartz, Anthropic, Code with Claude Tokyo: the same plan in Markdown and in HTML.

Thariq Shihipar of Anthropic wrote the long form of this argument in The unreasonable effectiveness of HTML. His reasons: HTML holds tables, diagrams and controls; long Markdown files do not get read; and a page with a “copy as prompt” button sends your decision back to the agent.

In November, at AI Engineer Shanghai, Bin Liu, VP of Product Engineering at HeyGen, took the idea further. HeyGen described its videos in its own JSON format. Agents wrote valid JSON, but valid did not mean correct.

HeyGen slide 'Agents aren't trained to write our JSON'. Two valid JSON objects for the text 'Launch day': the first renders correctly, the second puts the text off screen at size 240.
Bin Liu, HeyGen, AI Engineer Shanghai: both objects pass validation. Only one renders correctly.

So HeyGen dropped the JSON. Each video is now an HTML page, rendered to video in a headless browser. They published the renderer as HyperFrames, under Apache 2.0. His argument: models already know HTML from the whole web. Bet on the formats that models keep getting better at.

How we use HTML output today

We searched our own Claude Code sessions. From July to November 2026, agents made 97 HTML pages for us in 76 sessions. The number of sessions grew from 9 in July to 30 in October. Almost every page was for a decision: UI options side by side, a mockup before a ticket, a checklist for a directory listing, a gap analysis.

In the Tokyo workshop we built the same bill splitter as on the slide. After the interview, the agent wrote a page with the decisions at the top and four design directions below, each with mockups of the core screens.

HTML page 'Bill-Splitting App, 4 Design Directions'. Six cards show the decisions from the interview, then four cards: Balance-First, Activity Feed, Ledger and Conversational Quick-Add.
Our workshop output: the spec from the interview, then four design directions to choose from.

But in the same repositories we keep 2,622 plans and specs in Markdown. Those are the documents that agents execute, and that git tracks line by line. We never decided on this split. It happened, and the measurement below explains why it works.

We measured HTML vs Markdown

We wrote 10 planning tasks of the kind we give to agents: spend caps for an AI feature, a zero-downtime Postgres migration, an MCP server with OAuth, a choice between three check-in layouts, and six more. Each prompt asked for scope, options with a recommendation, steps, risks and open questions. Only the format line changed.

run.mjsbenchmark script, shortened
const FORMATS = {
  md: "Write the plan as a Markdown document.",
  html: "Write the plan as a single self-contained HTML file (inline CSS, no external assets).",
  visual: "Write the plan as a single self-contained HTML file (inline CSS and SVG, no external assets). Show the options side by side so they can be compared at a glance, draw the main flow or architecture as an inline SVG diagram, and include a simple mockup if the task has a user interface.",
};

We ran each task 3 times in Markdown and in plain HTML, and 2 times in visual HTML, on Claude Sonnet 5.5 with thinking off. So output tokens are the document only.

Markdown Plain HTML Visual HTML
Output tokens 5,400 10,254 14,934
Tokens vs Markdown, same task 1.0x 1.9x 2.7x
Time to finish 43 s 69 s 92 s
Cost per plan $0.054 $0.103 $0.150
Plans with an SVG diagram 0 of 30 0 of 30 20 of 20
10 tasks; 30 Markdown, 30 HTML and 20 visual HTML runs. Medians. Sonnet 5.5 list price.

“Write it as HTML” is not enough

Plain HTML cost more on every one of the 30 paired runs, from 1.5 to 2.5 times the tokens. It took 1.6 times as long. And it gave us almost nothing new. The visible text was only 18% longer than the Markdown version. No plan had a diagram or a control. The model wrote the same document in a nicer font, and the extra tokens were tags and CSS.

There was one more surprise. All 30 plain HTML answers came wrapped in a Markdown code fence, although the prompt said to reply with the document only. No Markdown answer had this problem. If HTML output goes into a product, strip and check it before you render it.

Ask for what Markdown cannot show

The visual prompt changed the result. Every one of the 20 plans had at least one SVG diagram, 43 in total. For the check-in task, the model drew three phone screens side by side and scored them against weighted criteria.

Generated HTML plan, section 'Options considered': three phone wireframes side by side for search-first, QR-scanner-first (marked recommended) and live attendee list, each with strengths and weaknesses.
Visual HTML output for the check-in task. The names on the screens are invented by the model.

That is the page the talks describe, and a reviewer decides from it in a minute. It costs 2.7 times the tokens of Markdown, about $0.10 more per plan. For a decision that one person reads, that is a small price. For an output that a product generates many thousands of times, it is a real line in the budget.

“The work is setting up the conditions in which the code gets written well.” (Jason Schwartz, Anthropic)

Where each format wins

  • HTML for decisions that people make. Options, mockups, diagrams and reports. Ask for the visual elements by name, or you pay for tags only.
  • Markdown for work that agents execute. Plans, CLAUDE.md files and guides. They are half the size or less, and a diff shows each change line by line.
  • A format the model knows, for product output. HeyGen’s lesson applies to any AI feature: a format of your own design is easy to validate and hard to get right. If you can, render a format the model has seen billions of times.
  • Measure before you scale. HTML output in a product feature multiplies your output tokens, and output tokens are the expensive ones.
What to copy

Keep plans that agents execute in Markdown. When you need a human decision, ask for HTML and name the elements: options side by side, a diagram, a mockup. As Thariq puts it, “The trick is always to end with an export”: give the page a button that copies the decision back to the agent as a prompt.

Limits of this test

This is one model, with thinking off, on 10 synthetic tasks and one prompt per format. We counted tokens, time and diagrams. We did not score whether the visual plans led to better decisions; that needs real reviewers. Token ratios also differ between tokenizers, so measure your own model before you plan a budget.

For the other talks we heard in Shanghai, read three talks on controlling agents. If you want to put AI output in front of your users or your team, see how we integrate AI into products.

Tadej Polajnar

Founder of TianSphere. Builds agents, eval harnesses and MCP servers for SaaS products, from Hong Kong.

Contact

Start a project.

Tell us about your product and where you want AI to help. We reply within one working day.

Or email us directly at [email protected]

Reply within 1 working day

We use your details only to reply. Privacy →