Back to feed
Dev.to
Dev.to
5/10/2026
XML Tags Don't Help Short Prompts — Here's When They Actually Matter (2026)

XML Tags Don't Help Short Prompts — Here's When They Actually Matter (2026)

Short summary

Experiment with Claude Sonnet 4.5 shows XML tags provide no accuracy improvement on short ~150-token prompts while adding 31% input token overhead. XML helps when prompts exceed 500 tokens with multiple sections or untrusted input, but wastes tokens on clear, templated prompts. Benchmark your own data before adopting best practices without testing.

  • XML provides no accuracy benefit for short, clear prompts (97.6% flat vs 96.4% XML)
  • XML adds 31% input token overhead—costs money for no gain on templated prompts
  • XML helps with 500+ token prompts with multiple sections; don't use it for 150-token extraction tasks

Generated with AI, which can make mistakes.

Is this a good recommendation for you?

Explore more