XML Tag Token Overhead Calculator

Measure the token cost of Anthropic-style XML tags in your Claude prompts.

Ad placeholder (leaderboard)

XML tag token overhead calculator

Claude follows structured prompts more reliably when you wrap sections in XML tags — but every <tag> and </tag> costs tokens on every call. This tool counts your prompt with tags, strips them to get the tagless equivalent, and reports the exact overhead so you can judge whether the structure pays for itself.

How it works

The calculator counts tokens for your prompt as written, then removes all XML tags with a markup-stripping pass and counts the plain-text version. The difference is your XML overhead, shown in both absolute tokens and as a percent of the tagged total. Token counts use the ≈ 4-characters-per-token heuristic that tracks Claude’s tokenizer closely for English text.

A single tag pair like <instructions>...</instructions> adds the opening and closing tags plus their angle brackets — usually a handful of tokens. The cost scales with how many sections you tag, not with the content inside them.

Tips for cost-effective tagging

  • Tag structure, not every sentence. Wrap the big sections — <document>, <instructions>, <examples>, <format> — not individual lines.
  • Reuse short tag names. <doc> costs fewer tokens than <reference_document> and Claude handles both equally well.
  • Skip tags on tiny prompts. A one-line instruction does not need a wrapper; the overhead is pure waste there.
  • Keep tags for long inputs. When you paste a large document, the few tokens of structure are negligible and the reliability gain is large.
Ad placeholder (rectangle)