Delimiters (XML Tags in Prompts)
A prompt often mixes several kinds of text: instructions, a pasted contract, a few examples and a user's question. Wrapping each part in a clearly named tag, such as <contract> and </contract>, tells the model where each part starts and ends and lets your instructions refer to it by name. Anthropic's prompting guide recommends XML tags for this. Any consistent scheme works, as long as the names are clear and you use them the same way every time.
Delimiters help with output too: ask for the answer inside <answer> tags and your code can extract it, or go further with structured output. They also help defensively, because marking untrusted content as data is the starting point for spotlighting. Tags alone won't stop a determined injection, so treat them as one layer of prompt injection defense. Qurtoo's article XML tags are the new markdown compares formats.
Example
Review the contract against our policy.
<policy>
Payment terms must be 30 days or shorter. Auto-renewal must require written notice.
</policy>
<contract>
{paste the contract here}
</contract>
List each clause in <contract> that conflicts with <policy>. Put your list inside <findings> tags, one clause per line, quoting the clause number.When to use it
- Prompts that combine instructions with documents, examples or user input
- Long prompts where the model must refer back to a specific part
- Outputs your code needs to parse
When not to use it
- Short one-line requests, where tags add clutter
- Relying on tags as your only protection against untrusted content
Articles that use this
- XML Tags Are the New Markdown: Why Closed Delimiters Beat Free-Form PromptsTechniques
- XML vs Markdown Prompts: How to Format One Prompt for Claude, GPT and GeminiTechniques
- How to Prompt Reasoning Models: OpenAI's Seven-Part Prompt Structure, ExplainedTechniques
- How to Write a System Prompt: Four Patterns From the Prompts AI Vendors PublishTechniques

