There is a formatting choice buried in every prompt you write, and almost nobody makes it on purpose. When you paste a role, a set of instructions, and some reference text into ChatGPT or Claude, how do you separate those pieces? Most people reach for Markdown headings out of habit. The more reliable answer, recommended by Anthropic, OpenAI and Google alike, is XML tags. This one change can turn a prompt that works most of the time into one that works almost every time.
This is not about writing code. XML tags in a prompt are just labelled brackets like <instructions> and </instructions> that fence off each part of your request. You can start using them in your next message, no technical setup required.
What are XML tags in a prompt?
XML tags are paired labels wrapped in angle brackets that mark where each section of your prompt begins and ends. A block like <context>...</context> tells the model exactly which text is background material and which text is your actual instruction. They are structural signposts, not programming.
The tags carry no magic meaning on their own. Their power is that they draw an unambiguous boundary the model can see, so it never confuses your instruction with the data it is supposed to act on.
Why are XML tags more reliable than Markdown headings?
XML tags are more reliable because they create closed boundaries with a clear start and end, while a Markdown heading only marks a beginning. When a section has no defined end, the model has to guess where your reference text stops and your instruction resumes, and under pressure it guesses wrong.
Anthropic's own prompt engineering documentation states that Claude was trained with attention to XML structure, and recommends tags for separating parts of a prompt. OpenAI and Google give similar guidance for their models.
Markdown was designed for human readability, not for machine-parseable structure. A ## Heading looks tidy to you, but to the model it is a weak signal that competes with every other ## in the document, including any that appear inside pasted content.
When do XML tags actually make a difference?
XML tags matter most when a prompt mixes several distinct ingredients: a role, instructions, reference documents, examples, and an output format. The more moving parts, the more a clear boundary prevents the model from blending them together.
For a one-line question like "summarise this email", tags add nothing. For a prompt that pastes a 2,000-word report and then asks for a structured analysis in a specific format, tags are the difference between a clean result and one where the model treats your instructions as part of the report.
They also defend against a common failure: when pasted text contains its own instructions ("ignore previous directions"), a fenced <document> block signals that everything inside is data to analyse, not commands to follow.
What does a real XML-structured prompt look like?
A well-structured prompt uses one tag per logical part: role, instructions, the input document, and the desired output format. Here is a complete, copy-paste-ready template you can adapt for almost any analysis task today.
Try this prompt:
<role>
You are a senior operations analyst writing for a busy department head.
</role>
<instructions>
Read the report inside the document tags. Produce three sections: a two-sentence summary, the three biggest risks, and one recommended action. Do not add any section not requested.
</instructions>
<document>
[Paste the full report text here]
</document>
<output_format>
Use these exact headings: Summary, Top Risks, Recommended Action. Keep the whole response under 200 words.
</output_format>
Because the instruction, the source text, and the format each sit in their own labelled block, the model stops guessing and starts following. Swap the contents of each block and the same skeleton handles report analysis, email drafting, or data extraction.
What are the common mistakes with XML prompting?
The most common mistake is opening a tag and never closing it, which removes the exact boundary that makes tags useful. Every <instructions> needs a matching </instructions>, or the structure collapses back into guesswork.
A second mistake is inventing a dozen deeply nested tags. Three to five clearly named blocks work better than an elaborate tree, because clarity, not complexity, is the goal.
A third mistake is inconsistent naming: opening with <context> and closing with </background>. Keep the opening and closing labels identical, and reuse the same names across your prompts so your own templates stay predictable.
When should you still use Markdown instead?
Markdown is the better choice when the priority is a short, readable prompt with no pasted reference material. For a quick instruction or a simple bulleted list of requirements, Markdown is lighter and adds fewer tokens.
XML tags are honestly more verbose. Every tag adds tokens, and on very long prompts that cost is real. The practical rule: use Markdown for short, single-purpose prompts, and switch to XML the moment you are combining instructions with a block of source text.
How can you test this in the next 20 minutes?
Take a prompt you already use that mixes instructions with pasted content, and run it twice: once in your current format, once wrapped in the XML template above. Compare how closely each output follows your format request.
Most people find the tagged version stays on-format far more consistently, especially as the pasted text gets longer. That single comparison usually settles the debate faster than any article can.
The takeaway
Structure is a skill, not a setting. The practitioners who get consistent output are not using secret models; they are drawing clean boundaries the model can actually see. XML tags are the simplest way to do that, and you already know enough to start.
At UD, that is the belief we build on: technology should quietly do the hard part so you can focus on the work. With UD, AI works for you, not the other way around, and after 28 years we are still here to make it feel that way.
Curious how sharp your AI instincts really are?
Knowing when to reach for XML over Markdown is exactly the kind of instinct that separates casual AI users from real power users. UD's AI IQ Test benchmarks where you stand, and if you want to go further, we'll walk you through every step of turning these techniques into a reliable daily workflow.