HTML vs markdown for Claude Code

Markdown for anything that lives in the repository. HTML when the structure is the content, such as a rendered page you want changed without redesigning it.

HTML vs markdown for Claude Code has a short answer. Use markdown for anything that lives in the repository, and HTML when you are asking for a change to a page that already exists.

A project instruction file in markdown. It reads the same in the editor and in a diff.
A project instruction file in markdown. It reads the same in the editor and in a diff.

That is the whole rule. The rest of this page is the reasoning, the cases where it flips, and the size cost of getting it wrong.

HTML vs markdown for Claude Code, in one table

Input Better format Why
Project instructions and notes Markdown Hand edited, reviewed in diffs, no layout to preserve
A specification with tables Markdown Pipe tables survive fine and stay readable
A page you want modified HTML Classes, structure and styling must be preserved
A rendered report to summarise Either Tags help a little, cost a little
A component to restyle HTML The markup is the subject of the request
A prompt template Markdown Shorter, and nothing about it is visual

The middle rows are the ones people get wrong. Asking for a layout change while describing the layout in prose produces a rewrite rather than an edit.

Why markdown wins inside the repository

Repository files are read by three audiences: the model, you, and the diff view during review.

Markdown is legible to all three. A heading is a hash, a list is a dash, and a changed line in a diff shows exactly what changed.

HTML in the same position adds opening and closing tags around every line. A one word change can appear as a modified block, and the reviewer has to look harder for the actual edit.

There is also the practical point that instruction files, changelogs and specifications are edited by hand more often than they are generated. Markdown is easier to hand edit.

A one word change in a markdown file and the same change in HTML. The markdown diff shows one line.
A one word change in a markdown file and the same change in HTML. The markdown diff shows one line.

Why HTML wins when the page is the subject

If the request is "make the second card full width on mobile", the model needs the actual markup. Class names, nesting order and the existing media queries are the material it works with.

Describing that page in markdown removes all of it. What comes back is a new page that happens to have similar content, which is a redesign you did not ask for.

The same applies to pages produced earlier in a chat. Paste the HTML back rather than the description, and the next version is an edit rather than a fresh attempt.

  • Restyling: give HTML.
  • Fixing a broken layout: give HTML, and say which browser and which width.
  • Adding a section to an existing report: give HTML so the new section matches.
  • Writing the content of a new report: markdown is fine, since there is nothing to preserve yet.

For repository pages, a file path beats a paste. The model reads the file and edits it in place, and you get a diff rather than a block of output to copy back.

The size cost, stated plainly

HTML is longer than markdown for the same visible content. Tags, attributes and closing tags are all characters.

The gap is widest for tables. A pipe table row is a handful of characters of syntax. The same row in HTML is a row tag plus a cell tag and closing tag per column.

The same table as a markdown pipe table and as HTML. The HTML version is several times longer.
The same table as a markdown pipe table and as HTML. The HTML version is several times longer.

That is a real cost when you are pasting a long document, and it is not a cost at all when you are pasting a page you want edited, because the tags are the thing being edited.

A middle route exists for long pages. Paste the section that matters rather than the whole file, keeping the enclosing structure so the model can see where it sits.

Output format is a separate decision

The input format does not determine the output format, and treating it as if it does is a common mistake.

  1. Result goes in a repository file. Ask for markdown, regardless of what you pasted in.
  2. Result is a page someone will open. Ask for a complete single file HTML document. Getting HTML instead of markdown covers the prompt shape.
  3. Result is an edit to an existing file. Ask for the edit, not the rewritten file, so review stays possible.
  4. Result is a summary for another prompt. Markdown, since nothing visual is at stake.

Mixing these produces the familiar annoyance of an HTML file that is mostly explanation, or a markdown document with stray tags in it.

Checking the page before the next round

When the output is a page, judging it from source costs a round trip. Render it and look at it.

The generated page rendered in a viewer, before the next round of corrections.
The generated page rendered in a viewer, before the next round of corrections.

Paste the file into the HTML viewer or into a NOS document. In a document the HTML renders exactly as written, including dark theme, charts and scripts, and the text stays clickable so small corrections do not need a new generation.

That closes most of the loop locally. A wrong heading, a wrong column order or a stale figure is a click and a keystroke rather than another prompt.

Editing AI generated HTML without code covers what can be fixed that way and what still needs a regeneration.

When the page needs to leave your machine

A file in the repository is not something a reviewer outside the project will open. Attachments get filtered, and a phone will not render an HTML file.

Giving the page an address solves that. Share, then Share link, then Create link, and the link is unlisted by default.

The address does not change when the page is edited, so the link you post in a pull request stays current.

Turning HTML into a link is the same step in one paste. For dashboards and reports that get regenerated weekly, keeping one document and replacing its content beats sending a new file each time.

Short version. Repository content, instructions, specifications and prompts: markdown. Pages you want changed rather than rewritten: HTML. Output format decided by the destination, never by the input.

If you are choosing formats for a longer running agent rather than a single session, HTML versus markdown for AI agents covers the extra considerations that appear when the model is reading many documents in a row.

Questions people ask

Should project instructions be markdown or HTML?

Markdown. Instruction files sit in the repository, get reviewed in diffs and get edited by hand. Markdown reads cleanly in all three situations. HTML adds tags that make the diff noisy without adding meaning.

When is HTML the better input?

When you are asking for a change to a page that already exists. Giving the actual HTML means the answer can preserve the classes, the layout and the styling. Describing the page in markdown throws that away and invites a redesign.

Does HTML cost more tokens than markdown?

Yes, for the same visible content, because tags and attributes are extra characters. The size difference is largest for tables and deeply nested layout. It is only worth paying when the structure is part of what you are asking about.

Can I paste a whole HTML page into Claude Code?

You can, but a file path is usually better. Point at the file in the repository so the model reads it directly and can edit in place. Pasting is for pages that do not live in the project yet.

What about the output format?

The same rule applies in reverse. Ask for markdown when the result goes into a repository file, and HTML when the result is a page someone will open. Do not let the input format decide the output format.

Keep reading