Skip to content

Using Delimiters and Tags in Prompts

How clearly marking documents, examples and instructions with tags or headings improves accuracy and safety.

Editorial team 1 min read

When a prompt mixes instructions, documents and examples, the model needs to know which is which. Delimiters make structure explicit.

Common Delimiters

  • XML-style tags: <document>…</document>, <example>…</example>, <instructions>…</instructions>.
  • Markdown headings: ## Context, ## Task.
  • Triple quotes or code fences for a block of text.

Many practitioners find XML-style tags especially clear for long, multi-part prompts.

Benefits

  • The model distinguishes material to analyse from instructions to follow.
  • Instructions can refer to parts by name: "Using only the text in <contract>…".
  • Outputs can be requested in tags for easy parsing: "Put your final answer in <answer> tags."
  • Reduces confusion when documents themselves contain instruction-like text.

Multiple Documents

Wrap each document separately with identifying attributes:

<documents>
<document id="1" title="Refund policy" date="2026-02-01">…</document>
<document id="2" title="Shipping policy" date="2025-11-10">…</document>
</documents>

Not a Security Boundary

Delimiters help the model understand structure, but they don't prevent prompt injection. Untrusted content can still influence behaviour.

Be Consistent

Use the same tag names throughout a prompt and across related prompts.

More in Prompting

All Prompting guides →
Prompting Guide · 1 min

Anatomy of an Effective Prompt

The parts of a prompt that reliably produce good results, with a template you can adapt for almost any task.

Prompting 1 min read 1 Nov 2025

Prompting Guide · 2 min

Giving Models Context

Why most weak outputs come from missing context, and what background information to include in a prompt.

Prompting 2 min read 31 Oct 2025

Prompting Guide · 1 min

Role Prompting: When It Helps and When It Doesn't

Telling a model to act as an expert or a persona can shape tone and focus — but it isn't a substitute for clear instructions.

Prompting 1 min read 30 Oct 2025