What are XML tags in prompts?
XML tags in a prompt are named, paired delimiters — an opening tag like `<context>` and a closing tag like `</context>` — that you wrap around a section of your prompt. They are not real XML that gets validated or parsed by a schema; they are simply a clear, consistent convention the model has seen extensively in training and reliably recognizes as structure.
The problem they solve is ambiguity. When you paste instructions, background, an example, and a user's document all into one prompt as plain prose, the model has to guess where each part begins and ends — and sometimes it treats your data as if it were an instruction, or blends an example into the real task. Wrapping each part in a labeled tag removes that guesswork.
Anthropic explicitly recommends XML tags as a core structuring technique for Claude, and provides example tag names in its prompt engineering documentation. The same idea — clear delimiters — appears in the DAIR.ai Prompt Engineering Guide and works across models.